DictionaryExtensionsGetOrAdd Method

Overload List

GetOrAddTKey, TValue(IDictionaryTKey, TValue, TKey, TValue) Adds a key/value pair to the dictionary if the key does not already exist, and returns either the added or the existing value. The operation is thread safe if dictionary is a ThreadSafeDictionaryTKey, TValue, ConcurrentDictionaryTKey, TValue or LockingDictionaryTKey, TValue instance. For other IDictionaryTKey, TValue implementations the caller should care about thread safety if needed.
GetOrAddTKey, TValue(IDictionaryTKey, TValue, TKey, FuncTKey, TValue) Adds a key/value pair to the dictionary by using the specified addValueFactory if the key does not already exist, and returns either the added or the existing value. The operation is thread safe if dictionary is a ThreadSafeDictionaryTKey, TValue, ConcurrentDictionaryTKey, TValue or LockingDictionaryTKey, TValue instance. For other IDictionaryTKey, TValue implementations the caller should care about thread safety if needed.
GetOrAddTKey, TValue, TArg(IDictionaryTKey, TValue, TKey, FuncTKey, TArg, TValue, TArg) Adds a key/value pair to the dictionary by using the specified addValueFactory if the key does not already exist, and returns either the added or the existing value. The operation is thread safe if dictionary is a ThreadSafeDictionaryTKey, TValue, ConcurrentDictionaryTKey, TValue or LockingDictionaryTKey, TValue instance. For other IDictionaryTKey, TValue implementations the caller should care about thread safety if needed.

See Also