光脚丫学LINQ(011):对源元素执行操作
时间:2010-10-29 来源:光脚丫思考
// Data source. double[] Radii = { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; // Results. IEnumerable<string> Results = from Rad in Radii select String.Format("Area = {0}", (Rad * Rad) * 3.14); // Results execution. foreach (string Result in Results) Console.WriteLine(Result); // Keep the console open in debug mode. Console.WriteLine("Press any key to exit."); Console.ReadKey() // Data source. double[] Radii = { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; // Results. IEnumerable<string> Results = from Rad in Radii select String.Format("Area = {0}", (Rad * Rad) * 3.14); // Results execution. foreach (string Result in Results) Console.WriteLine(Result); // Keep the console open in debug mode. Console.WriteLine("Press any key to exit."); Console.ReadKey()
输出如下:
Area = 3.14 Area = 12.56 Area = 28.26 Area = 50.24 Area = 78.5 Area = 113.04 Area = 153.86 Area = 200.96 Area = 254.34
相关阅读 更多 +