Finding array dimensions
How can i determine the dimensions of a multi dimensional array.
if i create a 2 dimensional array ( int [,] ) and read in some information (which will be variable in length)
can i i find the values for [x,y] of this array ?
i do not need the length, as this return all elements rather than the elements of each dimension.
There is no way to do this in C# that I've ever seen. But why does it matter?
If this array will vary in size from invocation, then when invoking your class (or wherever you invoke the array), save the params that were used for creating the size of the array. If your array is just constant then you can make some constants to define the size.
just did a quick search for something on this and came up with an artical which explains how to use Arraylists to create arrays where you cannot predetermine the length of the array.
this is only for a single dimension array but im sure you can see the need to be able to check this information once you have read in the data.
this may be useful to someone out there and save them a search :)
Sure, but arraylists aren't true arrays, and they aren't multidimensional. Perhaps you can make a list of structs to do what you need. Or if you really want a 2d array "type" that can expand and shrink, perhaps make a list of lists. This would allow you to iterate through each sub list on the list and add up the length.