Initialise multi dimension arrays

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Its easy enough to create and initialize a a 2D array of ints
as int[,] intarr = new int[,] {{1, 2}, {3, 4}, {5, 6}};, but how can i do
this with a 2D array of Point, or other multi init data types

Thanks
 
Cairn said:
Its easy enough to create and initialize a a 2D array of ints
as int[,] intarr = new int[,] {{1, 2}, {3, 4}, {5, 6}};, but how can i do
this with a 2D array of Point, or other multi init data types

Thanks

Just create values of the correct type for each position in the array:

Point[,] points = new Point[,] {{new Point(1,2), new Point(2,3)}, {new
Point(3,4), new Point(4,5)}, {new Point (5,6), new Point(6,7)}};
 
Back
Top