Remove a Key from Dictionary by key name

PositiveGuy picture PositiveGuy · Feb 29, 2012 · Viewed 77.4k times · Source

I'm trying to remove a key from my dictionary if the key is a certain key.

parameterList is a dictionary<string,string>

parameterList.Remove(parameterList.Where(k => String.Compare(k.Key, "someKeyName") == 0)); 

Answer

Ufuk Hacıoğulları picture Ufuk Hacıoğulları · Feb 29, 2012

This should be enough:

parameterList.Remove(key);