1
Answer

Instance of a class

adb8sapa

adb8sapa

20y
3.2k
1
Hi, Yesterday I was going through some code where I found this line: Cell[, ] Cells = null; I´ve never seen this way of making an instance from class before and thought mabey anyone here could explain what it does. The thing I dont understand is the "[, ]"-part in "Cell[, ]". The code I was going through is found at: http://www.c-sharpcorner.com/Code/2002/Sept/dfsmaze.asp (It´s in the zip file that follows, Maze.cs) I will highly appreciate any response given. Thanks.
Answers (1)
0
shimtanny

shimtanny

NA 440 0 20y
Hi Cell[, ] Cells = null; This line doesn't make an instance. It's just a declaration. It declares an tow dimensional array with Cell objects. Unfortunately the variable name was choosen the same as the class. Maybe it looks more clear the following way: Cell[,] myCells = null; Here is an example with another type than Cell: int[,] a = new int[2,5]; Simon