In this aritcle, we’ll learn How to find the length of an Array in C#.
C# Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
static void Main(string[] args) { 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(); } |
Output: