I am trying to remove all elements in an IDictionary that match a condition.
eg. IDictionary contains a set of keys and corresponding values ββ(say, 80 objects). Keys are strings, values ββcan be of different types (I think, extracting metadata from a wtv file using directshow).
Some of the keys contain thumb text, for example. thumbsize, startthumbdate etc. I want to remove all objects from an IDictionary whose keys contain the word thumb.
The only thing I see here is to manually specify each key name using the .Remove method.
Is there a way to get all the objects whose keys contain the word thumb and they remove them from the IDictionary.
The code is as follows:
IDictionary sourceAttrs = editor.GetAttributes();
GetAttributes is defined as:
public abstract IDictionary GetAttributes();
GetAttributes, IDictionary, , . (, HashTable)
UPDATE: Tim:
sourceAttrs = sourceAttrs.Keys.Cast<string>()
.Where(key => key.IndexOf("thumb", StringComparison.CurrentCultureIgnoreCase) == -1)
.ToDictionary(key => key, key => sourceAttrs[key]);