Answers for "c# alist how to get last element"

C#
1

c# get last item in list

using System.Linq; // make sure to use System.Linq

List<string> list = new List<string>
{
	"one",
	"two",
	"three",
};
var lastItem = list.LastOrDefault();
//Or
var lastItem = list.Last();
Posted by: Guest on November-16-2021
3

c# get last array element

string[] items = GetAllItems();
string lastItem = items[items.Length - 1];
int arrayLength = array.Length;
Posted by: Guest on May-19-2021

Code answers related to "c# alist how to get last element"

C# Answers by Framework

Browse Popular Code Answers by Language