匿名类:少了一个类型
var siz = new { id = 1, name = "xiaohua", size = 4, }; Console.WriteLine("{0},{1},{2}", siz.id, siz.name, siz.size);
委托:
public delegate string sd(int a, int b);
委托调用:包括匿名方法的使用
public void show() { sd s = new sd(this.qiu); sd s1 = new sd(delegate (int a, int b) { return (a + b).ToString(); }); Console.WriteLine(s.Invoke(3, 5)); } public string qiu(int a, int b) { return (a + b).ToString(); }
lambda表达式是一个匿名方法