-1
我想創建一個二維數組相當大的二維數組,這樣我就可以每次我點擊mouse..each行將代表光標位置添加新行..建立再C#
X1 Y1 x2 y2 x3 y3 。 。 。 。 。 。
i=0
private void Form1_MouseDown(object sender, MouseEventArgs e)
{
i++;
x[i]=e.X;
Y[i]=e.Y;
//if the array not exist create one
int[,] numbers = new int[i, 2]{{X[i], Y[i]}};
//if the array exist add row to the exist array
//add the row {{X[i], Y[i]} to the array
}
陣列是固定的大小。改用DataTable。 –
你應該真的使用一個結構或一個類,而不是'struct Pos {public int X; public int Y; }'。另外,使用列表來存儲它們。陣列是固定的大小不像列表 –