How do you retrieve the last element of an array in C#?
Array starts from index 0 and ends at n-1.
static void Main(string[] args) { int[] arr = { 1, 2, 3, 4, 5 }; int length = arr.Length - 1; // starts from 0 to n-1 Console.WriteLine(length); // this will give the last index. Console.Read(); }