View Single Post
Old 10-20-2006, 05:01 AM   #7 (permalink)
Ravatar
Forum Expert
 
Join Date: Sep 2002
Age: 23
Posts: 1,472
Default

Quote:
Originally Posted by Sep102
Or, put another way that isn't the slower way of doing it:
Code:
Int32 size1 = 250
    , size2 = 100;

Int32 [,] array = new Int32[size1, size2]
Note, that I'm not saying it's a bad way, just a slower way that doesn't take into account what the C# compiler intrinsically knows about.

Also, I'm not so sure that's what the OP wants. I'm thinking it's something along the lines of:
Code:
Int32 lowerSize = 100;
Int32 [,] array = new Int32[,size];
That is, leaving the upper bounds undetermined, which, as Courageous said, cannot be done using native arrays but can be done with other data structures.

There's something along the lines of what he's talking about in C++, but it doesn't really have to do with array initialization (still it's the first thing I thought of when reading his post):
Code:
void f(int a[][10])
{}

int main()
{
    int a[1][10];
    f(a);
}
But that's really just another way of saying "int (*a)[10]".

Of course, I could be wrong as well, just have to wait until they answer Courageous' question.
Yea.. for some reason I was under the impression you couldn't define array bounds at runtime. Guess I've been working in C++ too much recently.
Ravatar is offline   Reply With Quote