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 GETLENGTH function returns the length of a large object. The function returns an INTEGER value that reflects the length of the large object in bytes (for a BLOB) or characters (for a CLOB).
GetLength(Int32) Method is used to find the total number of elements present in the specified dimension of the Array. Syntax: public int GetLength (int dimension); Here, dimension is a zero-based dimension of the Array whose length needs to be determined.
GetLength returns the length of a specified dimension of a mulit-dimensional array. Length returns the sum of the total number of elements in all the dimensions.
An example of GetLength is GetLength(0) , which returns the number of elements in the first dimension of the Array.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With