C# | LongLength property of an Array
Array.LongLength Property is used to get a 64-bit integer that represents the total number of elements in all the dimensions of the Array.
Syntax:
public long LongLength { get; }
Property Value: This property returns a 64-bit integer that represents the total number of elements in all the dimensions of the Array.
Example:
// C# program to illustrate the // Array.LongLength Property using System; namespace geeksforgeeks { class GFG { // Main Method public static void Main() { // Two-dimensional array int[, ] intarray = new int[, ] { { 1, 2 }, { 3, 4 }, { 5, 6 }, { 7, 8 } }; // The same array with dimensions // specified 4 row and 2 column. int[, ] intarray_d = new int[4, 2] { { 1, 2 }, { 3, 4 }, { 5, 6 }, { 7, 8 } }; Console.Write("Total Number of Elements in intarray: "); // using LongLength property Console.Write(intarray.LongLength); // getting the type of returned value Console.WriteLine("\nType of returned Length: " + (intarray.LongLength).GetType()); // showing difference between Length // and LongLength property by getting // the type of the both property's // returned value Console.Write("\nTotal Number of Elements in intarray_d: "); // using Length property Console.Write(intarray_d.Length); // getting the type of returned value Console.WriteLine("\nType of returned Length: " + (intarray_d.Length).GetType()); Console.Write("\nTotal Number of Elements in intarray_d: "); // using LongLengthLength property Console.Write(intarray_d.LongLength); // getting the type of returned value Console.WriteLine("\nType of returned Length: " + (intarray_d.LongLength).GetType()); } } } |
Total Number of Elements in intarray: 8 Type of returned Length: System.Int64 Total Number of Elements in intarray_d: 8 Type of returned Length: System.Int32 Total Number of Elements in intarray_d: 8 Type of returned Length: System.Int64
Note: In the above program you can see that Array.Length property always returns the length of the type System.Int32 but Array.LongLength property always returns the length of the type System.Int64.
Reference:
Recommended Posts:
- Array.BinarySearch(Array, Object) Method with examples in C#
- C# | Array.BinarySearch(Array, Object, IComparer) Method
- C# | Array.BinarySearch(Array, Int32, Int32, Object, IComparer) Method
- Array.BinarySearch(Array, Int32, Int32, Object) Method with examples in C#
- Stack.Count Property in C#
- Stack.IsSynchronized Property in C#
- How to use AcceptsReturn Property of TextBox in C#?
- Console.KeyAvailable() Property in C#
- Thread.CurrentThread Property in C#
- StringBuilder.Chars[] Property in C#
- C# | SortedDictionary.Item[] Property
- C# | SortedDictionary.Values Property
- C# | SortedDictionary.Keys Property
- C# | SortedDictionary.Count Property
- Queue.IsSynchronized Property in C#
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.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.

