Filtering duplicates out of an IEnumerable
02:24 04 Nov 2009

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?

c#