GurdeepS
GurdeepS

Reputation: 67213

What is the difference between Rank and specifying [,] in an array?

In .NET, there is a Rank property for arrays.

What is the difference between this and specifiying something like:

int[,] intArray = new int[3,3]; ?

Which would be of Rank 2?

Thanks

Upvotes: 1

Views: 96

Answers (1)

Josh Lee
Josh Lee

Reputation: 177550

The Rank property is read-only. It is part of the type of the array and can only be set when the array is created. The expression int[,] refers to the type of rank 2 integer arrays, and you can create a rank 2 array either with the new int[n,m] syntax or with the Array.CreateInstance static method.

Upvotes: 1

Related Questions