Linq
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace linq1 { class Program { static void Main(string[] args) { int[] values = {2,3,4,5,46,56,67,576,-3,4 }; IEnumerable<int> e1 = values.Where(i => i > 0); foreach (int i in e1) { Console.WriteLine(i); } Console.WriteLine(values.Max()); Console.Read(); var p = new { Age=5,Name="tom"}; IEnumerable<int> e3 = values.Where(i => i > 0).OrderBy(i => i); var e2 = values.Where(i => i > 0).OrderBy(i => i); var e4 = from i in values where i > 10 orderby i descending select "[" + i + "]"; string[] value = { "fewf", "few", "grewg", " gre, greg, reg" }; var str = from item in value where item.Length < 5 select item; var str1 = from item1 in values let a=item1 where item1 > 100 select item1; Dictionary<string, int> dict = new Dictionary<string, int>(); dict["tom"] = 20; dict["tom"] = 30; dict["tom"] = 40; dict["tom"] = 30; var x1 = from name in dict.Keys where dict[name] > 20 select name; string.Join(",", x1); //分隔开 } } }