10.3.4 用 Select 方法和匿名类型进行投影
1 class Program 2 { 3 static void Main(string[] args) 4 { 5 var collection = Enumerable.Range(0, 10).Where(x => x % 2 != 0).Reverse().Select(x => new { Original = x, SquareRoot = Math.Sqrt(x) }); 6 foreach (var item in collection) 7 { 8 Console.WriteLine("sqrt {0} {1}", item.Original, item.SquareRoot); 9 } 10 11 Console.ReadKey(); 12 } 13 }