Get first item list in C#
To get First element of a list in C# you can directly use the methodFirst()
.Example
using System;
using System.Collections.Generic;
using System.Linq;
public class Client
{
public static void Main()
{
List<string> emptyList = new List<string>(new string[] { "One", "Two", "Three" });
Console.WriteLine(emptyList.First());
}
}
Output
One