top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to select unique names from a List using LINQ in C#?

+1 vote
377 views
How to select unique names from a List using LINQ in C#?
posted May 9, 2016 by Latha

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 select unique names from a List using LINQ in C#?

private static void Main(string[] args)

{

List<string> Names = new List<string>();

Names.Add("Abundantcode.com");

Names.Add("TestCode.com");

Names.Add("Abundantcode.com");

string[] AbundantArray = new string[] { "Abundantcode", "is", "a sourcecode site" };

var result = (from m in Names

select m).Distinct().ToList();

foreach(var item in result)

Console.WriteLine(item);

Console.ReadLine();

}

}

}
answer May 9, 2016 by Shivaranjini
...