I have a collection of longs List<long> myIds. I am populating the collection with id's. However I get some duplicates in the collection which I want to remove.
I have tried using distinct() on the collection but to no effect. Reordering and applying distinct() again did not help either.
What is the best way to remove these duplicates without writing custom logic?
I tried this:
mydIds.OrderBy(x => x).Distinct().ToList();
mydIds = mydIds.OrderBy(x => x).Distinct().ToList()?longvalues from a collection via LINQ'sDistinctcall; noOrderBynecessary.