-1

I want to remove duplicate value remain one with LINQ

Example:

{2,4,5,2,6,2,8,6,9}

Result:

{4,5,2,8,6,9}
Jayrag Pareek
  • 354
  • 3
  • 15

1 Answers1

1

Assuming your list is like:

var x = new List<int> {2,4,5,2,6,2,8,6,9};

You can distinct it:

var y = x.Distinct();

If you need the result as a List<T> rather than an enumerable, ToList() it (but if all you're doing is eg looping over it, don't bother: foreach(var unique in x.Distinct()))

Caius Jard
  • 72,509
  • 5
  • 49
  • 80