top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to Get the Last Element from LINQ Query in C#?

+1 vote
369 views
How to Get the Last Element from LINQ Query in C#?
posted May 4, 2016 by Sathaybama

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes
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();

}

}

}
answer May 4, 2016 by Shivaranjini
...