Write C# Program to get the Length of the Array

Introduction

I have used Visual Studio 2012 for debugging purpose. But you can use any version of visul studio as per your availability.

using System;
class Program
{
    static void Main()
    {
 
        int[] arrayA = new int[10];
        int lengthA = arrayA.Length;
        Console.WriteLine("Length of ArrayA : {0}", +lengthA);
        long longLength = arrayA.LongLength;
        Console.WriteLine("Length of the Long Length Array  : {0}", longLength);
        int[,] twoD = new int[20, 50];
        Console.WriteLine("The Size of 2D Array is : {0}", twoD.Length);
        Console.ReadLine();
    }
}

Result

Write C# Program to get the Length of the Array
Write C# Program to get the Length of the Array

Leave a Comment