摘要: 3.自动实现属性 在.NET2.0中属性是这样写的 //私有字段 private string _name;//共有字段 public string Name { get { return _name; } set { _name = value; } } 可是.NET3.0新加入一种写法 public string Name { get; set; } 3.0中他更简洁了,可实际上编译器编译的时候是有私有字段的 阅读全文
posted @ 2011-11-16 15:43 暗黑地狱风 阅读(115) 评论(0) 推荐(0) 编辑
摘要: 2.隐式类型 在.NET2.0中我们定义数据类型的时候一般 int i =1;//或int a;a =1; 在.NET3.0加入了隐式类型Var //隐式类型写法: var i = 1;//隐式类型会根据i的赋值来识别是什么类型 //错误写法1 var i = 1; i = "a"; //因为i已经赋值为int 类型1了后面在给i赋值为“a”string类型因为前面是int类型后面是string类型所以他们类型错误 //错误写法2 ... 阅读全文
posted @ 2011-11-16 15:35 暗黑地狱风 阅读(117) 评论(0) 推荐(0) 编辑
摘要: c#3.0加入的一些新特性1.泛型集合2.隐式类型3.自动实现属性3.匿名方法4.扩展方法5.Lambda表达式1.泛型集合 在.NET2.0中没有泛型集合定义集合用ArrayList定义很麻烦,现在.NET3.0加入泛型集合。在usingSystem.Collections;命名空间的List<“T”>"T"代表类型可以是简单类型或自己定义的类型。泛型集合写法:View Code List<string> list = new List<string>(); list.Add("abc"); list.Add(&qu 阅读全文
posted @ 2011-11-16 15:17 暗黑地狱风 阅读(115) 评论(0) 推荐(0) 编辑