How to remove Duplicates from List

Muhammad Waseem
Become .NET Pro !
Feb 9, 2023

There are multiple ways to remove duplicates from List in C# , In this article I have described four ways with implementation

1) Iterate and push one by one to unique List if it doesn’t exist

2) Use LINQ Distinct method

3) By using ToHashSet method which removes the duplicates

4) Group By

First method with Empty List and iteration with contains method is most efficient b/w them.

If you want to help the author in growing

  1. Subscribe my Weekly .NET Newsletter of C#/.NET
  2. Follow me on LinkedIn/Twitter OR Clap at least 50 times.
  3. Get exclusive .NET Questions & Answers by becoming a Patron.
  4. Download my eBook at Gumroad that contains 30 .NET Tips.

--

--