Home »
.Net »
C# Programs
C# - Array.LongLength Property Example
Here, we are going to learn how to demonstrate the example of LongLength property of array in C#?
Submitted by Nidhi, on August 22, 2020 [Last updated : March 19, 2023]
Here we create an integer array and use LongLength property of array to get the 64-bit length of the array.
C# program to demonstrate the example of Array.LongLength Property
The source code to demonstrate the LongLength property of an array in C# is given below. The given program is compiled and executed successfully on Microsoft Visual Studio.
//Program to demonstrate LongLength
//property of Array in C#.
using System;
class Program
{
static void Main()
{
int[] intArray = new int[500];
long len64 = intArray.LongLength;
Console.WriteLine("LongLength of intArray : "+len64);
}
}
Output
LongLength of intArray : 500
Press any key to continue . . .
Explanation
In the above program, we created a program class that contains the Main() method. In the Main() method we created integer array intArray with size 500. Then we used LongLength property. The LongLength property is used to get the 64-bit length of the array, it returns a long value instead of an int value. Then we printed the len64 variable on the console screen.
C# Basic Programs »