top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

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

0 votes
413 views
How to select unique names from a List using LINQ in C#?
posted Jul 27, 2016 by Sathyasree

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 Jul 27, 2016 by Shivaranjini
...