C#3.0 新特性系列(4) Object Initializers

代码如下:

 1 public class Mobile
 2 
 3 {
 4 
 5 public int Length { getset; }
 6 
 7 public int Width { getset; }
 8 
 9 }
10 
11 public class Program
12 {
13 static void Main()
14 {
15 Mobile m = new Mobile {Length = 9, Width = 9};
16 }
17 }
posted @ 2008-07-29 14:59  许晓光  阅读(166)  评论(0编辑  收藏  举报