December 2001
Intermediate to advanced
416 pages
8h 16m
English
All C# array types have access to the System.Array class public methods and properties. For example, the Length property returns the number of elements in an array:
for ( int ix = 0; ix < fib.Length; ++ix )
If the array is multidimensional, Length is a less useful property. For example, for the following array declaration:
static float [,] mat = new float[4,5]
{
{ 1f, 0f, 0f, 0f, 0f },
{ 0f, 1f, 0f, 0f, 0f },
{ 0f, 0f, 1f, 0f, 0f },
{ 0f, 0f, 0f, 1f, 0f }
};
the result of Length is 20. To retrieve the length of the individual dimensions of a multidimensional array, we use GetLength(int dim), where dim represents the number of the dimension: 0, 1, 2, and so on. To discover the number of dimensions associated ...
Read now
Unlock full access