首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

C# 对象数组的初始化有关问题

2012-04-03 
C# 对象数组的初始化问题student []anew student[2]{}student是带有string和int 这2个类型的数据成员的

C# 对象数组的初始化问题
student []a=new student[2]{};
student是带有string和int 这2个类型的数据成员的类
求教能不能直接像整形数组一样直接在大括弧里加数据:int []a=new int[2]{1,2};

[解决办法]
student[] a = new student[]
{
new student() { Name = "aa" },
new student() { Name = "bb" }
};

热点排行