VOOZH about

URL: https://www.geeksforgeeks.org/c-sharp/total-number-of-elements-in-a-specified-dimension-of-an-array-in-c-sharp/

⇱ Total number of elements in a specified dimension of an Array in C# - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Total number of elements in a specified dimension of an Array in C#

Last Updated : 11 Jul, 2025
Array.GetLongLength(Int32) Method is used to get a 64-bit integer that represents the number of elements in the specified dimension of the Array. Syntax:
public long GetLongLength (int dimension);
Here, dimension is the zero-based dimension of the Array whose length is to be calculated. Return Value: It returns a 64-bit integer that represents the number of elements in the specified dimension. Exception: This method throws IndexOutOfRangeException if the dimension is less than zero or greater than or equal to Rank. Example:
Output:
Total Number of Elements in first dimension of arr: 3
Type of returned Length: System.Int64

Total Number of Elements in second dimension of arr: 3
Type of returned Length: System.Int32

Total Number of Elements in second dimension of arr: 3
Type of returned Length: System.Int64
Note: In the above program, GetLength method return type is System.Int32 but the GetLongLength method return type is System.Int64. Reference:
Comment
Article Tags:

Explore