Tech Study

C# Program to get Length of 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

 

Here are some more c# programs for your practice :

C# program to count total duplicate elements in an array

Convert Base64 string to Byte Array using C#

TaggedWrite C# Program to get the Length of the Array

Java Final keyword

Introduction : java final keyword The final keyword present in Java programming language is generally used for restricting the user. …

Read more

C++ Memory Management: new and delete

C++ Memory Management We know that arrays store contiguous and the same type of memory blocks, so memory is allocated …

Read more