- 隐式类型的声明
var i = 1; // int
var a = new int[] { 1, 2, 3, 4, 5 }; // int[] - 自动属性(Automatic Properties)
public class Cell {
//行属性
public string Row { get; set; }
public string Col { get; set; }
} - 对象初始化器
var cell = new Cell
{
Row = 1,
Col = 1
}; - 集合初始化器
var intList = new List { 1, 2, 3, 4, 5 }; - 匿名类型
var a = new { Row = 1, Col=1}; - 扩展方法
static class TestExtensions
{
public static void AsString(this Cell cell)
{
return cell.Row.ToString()+cell.Col.ToString();
}