Removing duplicates from a list in C #

To remove duplicates from a list in C# we can use the Distinct function:

List<string> ListwithoutDuplicates = ListwithDuplicates.Distinct().ToList();

The list ListwithoutDuplicates will be free of all duplicate values present in the original list.

Leave a Comment

Your email address will not be published. Required fields are marked *