Array.GetLength(Int32) Method is used to find the total number of elements present in the specified dimension of the Array.
public int GetLength (int dimension);
Here, dimension is a zero-based dimension of the Array whose length needs to be determined.
Return value: The return type of this method is System.Int32. This method return a 32-bit integer that represents the number of elements in the specified dimension.
Exception:This method will give IndexOutOfRangeException if the value of dimension is less than zero or if the value of dimension is equal to or greater than Rank.
Below given are some examples to understand the implementation in a better way:
The elements of myarray : 445 44 66 6666667 78 878 1 Total Elements: 7
myarray1 and myarray2: False myarray1 and myarray3: True
- Total number of elements in a specified dimension of an Array in C#
- C# | Count the total number of elements in the List
- How to set the Height of the Elements present in the ListBox in C#?
- Count the number of element present in the sequence in LINQ?
- Getting the Total Number of Days in a Month Using If-else and Switch Statements in C#
- How to Get a Total Number of Days in a Month using built in Functions in C#?
- How to set the Font of the Content present in the RichTextBox in C#?
- How to change the case of the characters present in the TextBox in C#?
- How to set the font of the content present in the ComboBox in C#?
- How to set the Font of the Content Present in the Label in C#?
- How to Highlight the Text Present in the MaskedTextBox in C#?
- How to set the Font of Content present in the GroupBox in C#?
- C# | Copy the elements of collection over a range of elements in ArrayList
- C# | Copying the elements of ArrayList to a new array
- C# | Copy the elements of a string array to the end of the StringCollection
- C# | Copying BitArray elements to an Array
- C# | Copying the Collection<T> elements to an array
- C# | Check if an array contain the elements that match the specified conditions
- C# | Copying the Hashtable elements to an Array Instance
- C# | Copy OrderedDictionary elements to Array instance at the specified index
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.