How to get DISTINCT items from List - using Linq



In this Blog you will have simple solution to get the DISTINCT items from List of Strings.


      
 public static List<string> GetDistinctItems(List<string> duplicateItems)

        {

            return (from dItem in duplicateItems select dItem).Distinct().ToList();

        }


In this above single line static method  the Distinct() of Linq statement has been used to return the DISTINCT items from List of strings.

Thanks.