In this example i’ll show you, How to get the last element from an array using C#.
C# Code:
1 2 3 4 5 6 7 8 9 10 11 |
static void Main(string[] args) { string[] arr = { "C#", "Python", "C++", "Java" }; // Get the last string element. string last = arr[arr.Length - 1]; Console.WriteLine("LAST ELEMENT: {0}", last); Console.ReadLine(); } |
Output