I have a list of duplicate names and I want to get the list without the duplicates.
CSVCategories = from line in File.ReadAllLines(path).Skip(1)
let columns = line.Split(',')
select new Category
{
Name = columns[9]
};
var results = CSVCategories.GroupBy(x => x.Name)
.Select(g => g.FirstOrDefault())
.ToList();
I try to look at the elements and debug using the following loop, but it still returns the duplicates from the list including empty strings for null values:
foreach(var item in results)
{
Console.WriteLine(item.Name);
}