1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| delegate bool MyBol(int x, int y); delegate bool MyBol_2(int x, string y); delegate int calculator(int x, int y); delegate void VS(); static void Main() { MyBol Bol = (x, y) => x == y; MyBol_2 Bol_2 = (x, s) => s.Length > x; calculator C = (X, Y) => X * Y; VS S = () => Console.Write("我是无参数Labada表达式"); int[] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 }; int oddNumbers = numbers.Count(n => n % 2 == 1); List<People> people = LoadData(); IEnumerable<People> results = people.Where(delegate(People p) { return p.age > 20; }); } private static List<People> LoadData() { List<People> people = new List<People>(); People p1 = new People(21, "guojing"); People p2 = new People(21, "wujunmin"); People p3 = new People(20, "muqing"); People p4 = new People(23, "lupan"); people.Add(p1); people.Add(p2); people.Add(p3); people.Add(p4); return people; } public class People { public int age { get; set; } public string name { get; set; } public People(int age, string name) { this.age = age; this.name = name; } }
|