c# get last item in list to the first item in the list code example

Example 1: f# get last element of list

Seq.last lst

Example 2: 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);

Example 3: get first and last item list c#

List<string> _ids = new List<string>() { "aaa", "bbb", "ccc", "ddd" };
var first = _ids[0]; //first element
var last = _ids[_ids.Count - 1]; //last element