该代码是并行运行的多个行,但所有的列顺序..
/*************ADDING two 2-d ARRAYS*********/
int[,] c = new int[2,3];
int[,] a = { { 1, 2, 3 }, { 4, 5, 6 } };
int[,] b = { { 1, 2, 3 }, { 4, 5, 6 } };
int j;
// Console.WriteLine(c.Length / 2); To get the length of second dimention of an array.
Parallel.For(0, c.Length / 2, (int i) =>
{
for (j = 0; j < 3; j++)
{
c[i, j] = a[i, j] + b[i, j];
Console.WriteLine("c[" + i + "," + j + "] = " + c[i, j]);
}
}
);