+ 1

How to put 2 poins in a 2d array in C#

I have class point with properties and I need to put an x and y point in 2d array and it s something like this: Point[,] p = new Point [100,2]; Main p[0,0].x = Convert.ToInt32(textbox1.text) // how would this inicialization be correct ???

29th Dec 2018, 7:36 PM
Dejan
Dejan - avatar
3 ответов
+ 2
Doesn't it work as: Point[][] p = new Point(); ? And changing values as: p[x][y] = z;
29th Dec 2018, 8:07 PM
Seb TheS
Seb TheS - avatar
+ 2
Its throws me exception null reference 'Object reference not set to an instance of an object,
29th Dec 2018, 10:40 PM
Dejan
Dejan - avatar
+ 1
maybe you should add parentheses within the creation: Point[,] p = new Point([100, 2])
30th Dec 2018, 11:25 AM
Seb TheS
Seb TheS - avatar