【发布时间】:2021-03-22 22:51:20
【问题描述】:
有这么一个数组,我通过Thread知道需要什么,但是不明白怎么做。您是否需要将数组拆分为多个部分,或者您可以立即做某事吗?
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
int[] a = new int[10000];
Random rand = new Random();
for (int i = 0; i < a.Length; i++)
{
a[i] = rand.Next(-100, 100);
}
foreach (var p in a)
Console.WriteLine(p);
TimeSpan ts = stopWatch.Elapsed;
stopWatch.Stop();
string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
ts.Hours, ts.Minutes, ts.Seconds,
ts.Milliseconds / 10);
Console.WriteLine("RunTime " + elapsedTime);
【问题讨论】:
-
正如您从答案中了解到的那样,这是您通常不想做的事情,尽管这肯定是一个很好的教学练习。