How do you retrieve the last element of an array in C#?
LINQ provides Last():
csharp> int[] nums = {1,2,3,4,5}; csharp> nums.Last(); 5
This is handy when you don't want to make a variable unnecessarily.
string lastName = "Abraham Lincoln".Split().Last();
1.4m articles
1.4m replys
5 comments
57.0k users