How do I remove dupliactes in a collection? For example:
List<double> somelist=new List<double>{2, 2, 3};
What LINQ method should I use?
And try to make it simple please.
How do I remove dupliactes in a collection? For example:
List<double> somelist=new List<double>{2, 2, 3};
What LINQ method should I use?
And try to make it simple please.
Enumerable.Distinct is probably what you're looking for.
var somelist = new List<double>{2, 2, 3}.Distinct();
// somelist now contains 2, 3
I would suggest using a HashSet<double>
instead of List<double>
.