c# get last element in list code example
Example 1: c# get the last item in a list
var lastItem = integerList.Last();
Example 2: get last element in a list vb.net
if(integerList.Count>0)
{
var item = integerList[integerList.Count - 1];
}
Example 3: f# get last element of list
Seq.last lst
Example 4: get first and last item list c#
List<string> _ids = new List<string>() { "aaa", "bbb", "ccc", "ddd" };
var first = _ids.First();
var last = _ids.Last();
Console.WriteLine(first);
Console.WriteLine(last);