What does the Arguments of GetLength mean? for example
value.GetLength(1)
where value is a two dimensional Array double[,] What will changing 0 and 1 differ in?
What does the Arguments of GetLength mean? for example
value.GetLength(1)
where value is a two dimensional Array double[,] What will changing 0 and 1 differ in?
The argument for GetLength method specifies the dimension. The method returns the number of elements in the specified dimension. Example with a two dimensional array:
class Program
{
static void Main()
{
var a = new int[5, 4];
Console.WriteLine(a.GetLength(0));
Console.WriteLine(a.GetLength(1));
}
}
prints 5
and 4
on the screen.
GetLength(i)
returns the number of elements in the i
th dimension. So for a two-dimensional array GetLength(0)
returns the number of rows and GetLength(1)
returns the number of columns.