zoukankan
html css js c++ java
foreach 的自动转化类型
namespace
WindowsApplication9
{
public
partial
class
Form1 : Form
{
public
Form1()
{
InitializeComponent();
}
private
void
Form1_Load(
object
sender, EventArgs e)
{
object
[] persons
=
new
object
[
3
];
persons[
0
]
=
(
new
Person(
"
x
"
));
persons[
1
]
=
(
new
Person(
"
y
"
));
persons[
2
]
=
(
new
Person(
"
z
"
));
//
从persons中取出的成员是object类,foreach会自动将其转化为目标类型
foreach
(Person person
in
persons)
{
MessageBox.Show(person.Name);
}
}
}
public
class
Person
{
public
string
Name;
public
Person(
string
n)
{
this
.Name
=
n;
}
}
}
查看全文
相关阅读:
优雅的windowsC++项目的配置
C++实现编码转换
C++读取配置文件
完全依赖QML实现播放器
记一次和“N+1”的擦肩而过
FFmpeg4.0笔记:采集系统声音
FFmpeg4.0笔记:采集桌面
FFmpeg4.0笔记:封装ffmpeg的解封装功能类CDemux
SDL2:封装媒体显示播放Csdl2
FFmpeg4.0笔记:封装ffmpeg的音频重采样功能类CSwr
原文地址:https://www.cnblogs.com/shcity/p/983843.html
最新文章
关于从网页上下载数据
osgb的顶点,纹理,索引,UV读取与存储
OSG :三维无序离散点构建Delaunay三角网
三维空间求三角形的外心
VS2015 导航栏 查看每个cpp文件中类以及类成员函数的框框
QT QProgressBar QProgressDialog 模态,位置设置,无边框,进度条样式
Unigine mesh顶点坐标转换精度问题
QT 子窗口退出全屏
OSG 改变窗口大小
聊一聊Dubbo的一些特性和原理
热门文章
掀开Dubbo的盖头来
序列化与反序列化
聊一个自己写的MVC框架
自言自语Spring依赖注入(XML配置)
Spring-BeanFactory基本工作流程
浅谈MyBatis之Mapper文件
MyBatis概述
个人感悟之设计模式应用场景
hugo搭建的个人博客
字符动画播放器,不止BadApple!
Copyright © 2011-2022 走看看