C#3.0语言新特性

  1. 隐式类型的声明
    var i = 1; // int 
    var a = new int[] { 1, 2, 3, 4, 5 }; // int[] 
  2. 自动属性(Automatic Properties)
     public class Cell {
            //行属性
            public string Row { get; set; }  
            public string Col { get; set; }        
        }
  3. 对象初始化器 
     var cell = new Cell

    Row = 1,  
    Col = 1
    };
  4. 集合初始化器
    var intList = new List { 1, 2, 3, 4, 5 }; 
  5. 匿名类型
     var a = new { Row = 1, Col=1};
  6. 扩展方法
    static class TestExtensions
    {
    public static void AsString(this Cell cell)
    {
    return cell.Row.ToString()+cell.Col.ToString();


 

posted on 2007-07-07 14:26  周 金根  阅读(308)  评论(0编辑  收藏  举报

导航