![](/img/trans.png)
[英]How to create single dimensional, two dimensional,three dimensional as well as multi dimensional array using C#?
[英]create a re sizable two dimensional array 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
}
您需要的是System.Drawing.Point列表。 點同時具有X和Y。
private List<Point> points = new List<Point>();
private void Form1_MouseDown(object sender, MouseEventArgs e)
{
points.Add(e.Location);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.