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));
How to Remove an Element from a List Using the remove() Method in Python. To remove an element from a list using the remove() method, specify the value of that element and pass it as an argument to the method. remove() will search the list to find it and remove it.
This should be enough:
parameterList.Remove(key);
Simply remove by key:
parameterList.Remove("someKeyName");
To check:
if (parameterList.Remove("someKeyName")) { // key removed } else { // dictionary doesn't contain the key }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With