Click or drag to resize
SafeDictionaryTKey, TValueAdd Method
Adds the value to the dictionary if it does not exist. Updates existing, if it does exist.

Namespace: CMS.Base
Assembly: CMS.Base (in CMS.Base.dll) Version: 10.0.0
Syntax
Examples
If you want to add some key-value pair only if it does not exist within the dictionary, use the following snippet to do so in a thread-safe way.
if (!dictionary.ContainsKey(myKey))
{
    lock (dictionary.SyncRoot)
    {
        if (!dictionary.ContainsKey(myKey))
        {
            dictionary.Add(myKey, myValue);
        }
    }
}
See Also