Here is my list of KeyValuePairs
List<KeyValuePair<string,string>> kvpair =new List<KeyValuePair<string,string>>()
sample data
"the brown fox", "xy the brown fox...."
"the brown Fox", "xy the brown Fox...."
"The brown Fox", "xy the brown Fox...."
"the brown fox", "xy the brown fox...."
"the brown fox", "xy the brown fox...."
"The black fox", "xy The black fox...."
As you can see there are too many duplicate records in the list. How can I skip all duplicates and get kvpair with only distict keys along with its corresponding value from the list. My expected result should contain only two records (ie., expected result should be as follows
"the brown Fox", "xy the brown Fox...."
"The black fox", "xy The black fox...."
)
I tried this, but not working as expected
var distinctKvPair=kvPair.Where(g => g.Key.Contains(g.Key, StringComparison.OrdinalIgnoreCase)).GroupBy(g=>g.Key) as List<KeyValuePair<string, string>>