惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
The GitHub Blog
The GitHub Blog
J
Java Code Geeks
Engineering at Meta
Engineering at Meta
N
Netflix TechBlog - Medium
A
About on SuperTechFans
博客园 - 三生石上(FineUI控件)
罗磊的独立博客
MongoDB | Blog
MongoDB | Blog
B
Blog RSS Feed
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
有赞技术团队
有赞技术团队
T
Tailwind CSS Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
Vercel News
Vercel News
腾讯CDC
博客园 - 聂微东
The Cloudflare Blog
F
Fortinet All Blogs
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
Visual Studio Blog
Last Week in AI
Last Week in AI
B
Blog

博客园 - shcity

Troubleshooting on TransactionScope Parse string to JSON object Parse date in js blockUI doesn't close when download file in asp.net define namespace in JS Dense_Rank(), Row_Number(), Rank() in sql server reading and writing variable through lock in SSIS script task Fix the issue that cannot open SSIS in BIDS three ways creating custom helpers to show RadioButtonList in MVC using JavaScriptSerializer to serialize object to json using ISerializable to control serialization and deserialization ViewStateAutoManager ReportingService formatting Build my own DataTable split a string into an array through comma div with separated html template - shcity 正则表达式替换日期 半透明的div对话框 在Ajax1.0中调用页面CS文件中的方法
foreach 的自动转化类型
shcity · 2007-12-05 · via 博客园 - shcity

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;
        }

    }

}

posted on 2007-12-05 16:55  shcity  阅读(380)  评论(0)    收藏  举报

刷新页面返回顶部