我怎样才能使下面的代码更高效,更少的行。
我将一些 PictureBox 元素添加到二维数组中。
int a = 0;
int b = 0;
for (int i = 0; i < 3; i++)
{
Console.WriteLine("Iteration: " + i + " a = " + a);
Console.WriteLine("Iteration: " + i + " b = " + b);
pictureBoxArr[a, b] = new PictureBox();
b++;
}
int aa = 1;
int bb = 0;
for (int i = 0; i < 3; i++)
{
Console.WriteLine("Iteration: " + i + " aa = " + aa);
Console.WriteLine("Iteration: " + i + " bb = " + bb);
pictureBoxArr[aa, bb] = new PictureBox();
bb++;
}
int aaa = 2;
int bbb = 0;
for (int i = 0; i < 3; i++)
{
Console.WriteLine("Iteration: " + i + " aaa = " + aaa);
Console.WriteLine("Iteration: " + i + " bbb = " + bbb);
pictureBoxArr[aaa, bbb] = new PictureBox();
bbb++;
}
我在想这样的事情-但我有点卡住了。
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; i++)
{
}
}