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,0 ,106 ,0 ,0 ,0 ,110 ,111 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,110 ,111 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 },
new int[]{31 ,32 ,0 ,0 ,107 ,0 ,0 ,0 ,56 ,57 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,56 ,57 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 },
new int[]{26 ,26 ,26 ,26 ,26 ,26 ,26 ,26 ,26 ,26 ,26 ,26 ,26 ,26 ,26 ,26 ,26 ,26 ,26 ,26 ,26 ,26 ,26 ,26 ,26 ,26 ,26 ,26 ,26 ,26 },
new int[]{27 ,27 ,27 ,27 ,27 ,27 ,27 ,27 ,27 ,27 ,27 ,27 ,27 ,27 ,27 ,27 ,27 ,27 ,27 ,27 ,27 ,27 ,27 ,27 ,27 ,27 ,27 ,27 ,27 ,27 },
};
Now I want another array to hold these arrays so I can choose a random jagged array from it.
I did:
int[][][] mapArray = {map0,map1..};
But it gives me a compiler error saying An object reference is required for the non static field, method, or property 'map0'
int[int[][]]
doesnt work either
Upvotes: 0
Views: 131
Reputation: 203814
You cannot refer to other instance fields when initializing an instance field. You'll need to initialize it in the constructor.
You are declaring the type of the object entirely correctly; there's nothing to change there.
Upvotes: 1