I'm learning C# and am from a Java + Python + D background. I'm accustomed to iterating over an array from zero to its upper bound, through code such as the following (in Java):
for(int i = 0; i < array.length; i++)
But C#, for multidimensional arrays, I can't get the length of an individual dimension-- .Length on a multidimensional array gets the total number of available elements. Jagged arrays might be an exception, but they aren't what I'm working with. To get a specific dimension, I've had to use .GetUpperBound(...) , which returns the length of the array minus one.
Before I jump to any conclusions, is there a reason for it to be doing this, and cutting against a trend in C-style programming languages stretching back to at least 1972? Is there an easy way to get that value other than .GetUpperBound(...) - 1? It feels very messy to me.
Thank you!