How do you find the length of an array in C#?

CsharpProgrammingServer Side Programming

To find the length of an array, use the Array.Length() method.


Let us see an example −

 Live Demo

using System;
class Program {
   static void Main(){
      int[] arr = new int[10];
      // finding length
      int arrLength = arr.Length;
      Console.WriteLine("Length of the array: "+arrLength);


Length of the array: 10

Above, we have an array −

int[] arr = new int[10];

Now to find the length, we used the Length() method −

int arrLength = arr.Length;
Updated on 20-Jun-2020 10:48:01