Filtering duplicates out of an IEnumerable
I have this code:
class MyObj {
int Id;
string Name;
string Location;
}
IEnumerable list;
I want to convert list to a dictionary like this:
list.ToDictionary(x => x.Name);
but it tells me I have duplicate keys. How can I keep only the first item for each key?