许明会的计算机技术主页

Language:C,C++,.NET Framework(C#)
Thinking:Design Pattern,Algorithm,WPF,Windows Internals
Database:SQLServer,Oracle,MySQL,PostSQL
IT:MCITP,Exchange,Lync,Virtualization,CCNP

导航

C#3.0技术探讨(4):集合初始化器Collection Initializer

/*--===------------------------------------------===---
集合初始化器: Collection Initializer

            许明会    2007/12/3 19:41
--===------------------------------------------===---
*/
using System;
using System.Collections.Generic;

namespace xumh
{
    
public class student
    {
        
public string Name{get;set;}
        
public int Age{get;set;}
        
public string Address{get;set;}
    };

    
public class runMyApp
    {
        
static void Main()
        {
            List
<student> stu = new List<student> {
                
new student{Name="许明会", Age=36, Address="北大青鸟"},
                
new student{Name="林松涛", Age=34, Address="正海集团"},
                
new student{Name="刘向阳", Age=35, Address="LG伊诺特"}
            };

            
foreach(var v in stu)
            {
                Console.WriteLine(
"{0},今年{1}岁,就职于{2}",
                    v.Name, v.Age, v.Address);
            }
        }
    };
}

posted on 2007-12-03 19:52  许明会  阅读(239)  评论(0编辑  收藏  举报