using System;
using System.Text;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using System.Diagnostics;
using System.Linq;
namespace Test
{
class Program
{
public static string DateTime_Now_ToString()
{
return DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
}
static void Main()
{
var intArray = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
var result = from t in intArray.AsParallel()
select t * t;
foreach (var item in result)
{
Console.WriteLine(item.ToString());
}
Console.WriteLine("\nAsOrdered():");
var result2 = from t in intArray.AsParallel().AsOrdered()
select t * t;
foreach (var item in result2)
{
Console.WriteLine(item.ToString());
}
Console.WriteLine("\n执行完成" + DateTime_Now_ToString());
Console.ReadLine();
}
}
}
/*
16
49
81
1
25
64
100
4
36
9
AsOrdered():
1
4
9
16
25
36
49
64
81
100
执行完成2016-08-31 14:24:32
*/