c sharp count length of array code example
Example 1: c# length of array
string[] weekDays;
weekDays = new string[] {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
Console.Write(weekDays.Length);
Example 2: c# count element in an array
string[] empty = new string[5];
var totalElements = empty.Count();
string[] animals = { "Cat", "Alligator", "fox", "donkey", "Cat", "alligator" };
totalElements = animals.Count();
int[] nums = { 1, 2, 3, 4, 3, 55, 23, 2, 5, 6, 2, 2 };
totalElements = nums.Count();