tags:

views:

43

answers:

3

I'm having a little trouble with an array I've defined.

int[] levelData = new int[450] {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,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,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};

From all the tutorials and webpages I've read, I can't find anything wrong with it. The error Visual C# gives me is:

"Invalid Rank Specifier: expected '[' or ','"

The Column Number it gives me points to the second number.

Any ideas as to what's wrong? It's been driving me crazy for hours.

+2  A: 

Did you try without the number 450, i.e int[] levelData = new int[] {, as the compiler should be able to deduct the length automatically (and maybe it even wants to do that, i.e. you shouldn't put a size in when you use initializers?).

inflagranti
Yeah that worked thanks :) - I think the debugger was running or something and that's why no matter what I tried, the same error came up.
Queeg
It could also have been, what was suggested by andyb, that the 450 didn't correspond with the actual number of values you provided in the initializer list. Also, given that I solved your problem, could you accept my answer? :)
inflagranti
A: 

The code you have posted works fine in VS2008 and VS 2010. So looks like you have not posted the correct thing. If you are getting Invalid Rank Specifier then the way you have initialized the array could be wrong.

Take a look at what is OK and NOT OK from this MSDN link http://msdn.microsoft.com/en-us/library/b6ax0bze(VS.80).aspx

Nitin Chaudhari
A: 

The declaration you have pasted works fine for me. Are you sure the error is on this line and this is exactly your code?

A common cause of this is if you don't initialize all the elements in your array. Make sure you have 450.

andyb
see community content comment on this page:http://msdn.microsoft.com/en-us/library/0a7fscd0%28VS.80%29.aspx
andyb