|
-
Dec 20th, 2007, 11:06 PM
#1
Thread Starter
Frenzied Member
[2.0] creating an array of 2D arrays O_O
I need to create an array of 2D arrays, how would I do this?
int myArray1[,] = new int[,] {{1}, {2}};
int myArray2[,] = new int[,] {{3}, {5}};
int myPointer[] = new int[] {myArray1, myArray2};
then be able to reference myArray1 & 2, and it's values...
I have tried this:
Code:
public int[,] grid_1 = new int[,]
{{0, 0, 0, 1, 0, 0, 0, 1, 0, 1,1},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 1,0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 2,0},
{0, 0, 0, 0, 0, 0, 0, 0, 1, 2,0},
{4, 0, 0, 0, 0, 0, 0, 0, 0, 0,0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0},
{0, 0, 0, 0, 1, 2, 0, 0, 0, 0,0},
{0, 0, 0, 0, 1, 2, 1, 1, 0, 0,0},
{0, 0, 0, 0, 1, 0, 0, 0, 0, 0,0},
{0, 0, 0, 0, 1, 0, 0, 0, 0, 0,0}};
public Point[] gridChangePoints = new Point[]
{new Point(0, 4)};
public int[] gridList = new int[] { grid_1 }; //line 37
The error I get is:
Code:
A field initializer cannot reference the nonstatic field, method, or property '_D_Game.Form1.Grids.Havana.grid_1' Line 37
Code:
Cannot implicitly convert type 'int[*,*]' to 'int' Line 37
I do not understand what it means by this? does anyone know? and does anyone know the solution?
Thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|