Below is a sample source code demonstrating How to Get the Last Element from LINQ Query in C#?
How to Get the Last Element from LINQ Query in C#?
using System; using System.Collections.Generic; using System.Data; using System.Linq; namespace AbundantCode { internal class Program { //How to Get the Last Element from LINQ Query in C#? private static void Main(string[] args) { List<string> ABundantCodeVersions = new List<string> { "Abundantcodev1", "Abundantcodev2", "Abundantcode3" }; string NewData = (from m in ABundantCodeVersions select m).Last(); Console.WriteLine(NewData); Console.ReadLine(); } } }
Leave a Reply