对象初始化器,在创建对象时直接向对象赋值。可以提高代码的可读性。另外利用这个技术,可以创建匿名类型。
eg1: Book myBook=new Book(){
BookName="ASP.Net 4.0 学习",
ISBN="0000010",
Price=69
};
eg2: 集合初始化
int[] intArray={0,1,2,3,4,5,6,7,8,9};
List<int> intList=new List<int> {1,2,3,4,5,6,7,8,9,0};