ThreadSafeDictionaryTKey, TValueGetOrAddTArg(TKey, FuncTKey, TArg, TValue, TArg) Method
Adds a key/value pair to the
ThreadSafeDictionaryTKey, TValue by using the specified
addValueFactory
if the key does not already exist, and returns either the added or the existing value.
Namespace: KGySoft.CollectionsAssembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 10.0.0
public TValue GetOrAdd<TArg>(
TKey key,
Func<TKey, TArg, TValue> addValueFactory,
TArg factoryArgument
)
Public Function GetOrAdd(Of TArg) (
key As TKey,
addValueFactory As Func(Of TKey, TArg, TValue),
factoryArgument As TArg
) As TValue
public:
generic<typename TArg>
TValue GetOrAdd(
TKey key,
Func<TKey, TArg, TValue>^ addValueFactory,
TArg factoryArgument
)
member GetOrAdd :
key : 'TKey *
addValueFactory : Func<'TKey, 'TArg, 'TValue> *
factoryArgument : 'TArg -> 'TValue
- key TKey
- The key of the element to add or whose value should be returned.
- addValueFactory FuncTKey, TArg, TValue
- The delegate to be used to generate the value, if the key does not already exist.
- factoryArgument TArg
- An argument to pass into addValueFactory.
- TArg
- The type of an argument to pass into addValueFactory.
TValueThe value for the key. This will be either the existing value for the
key if the key is already in the dictionary,
or the result of the specified
addValueFactory if the key was not in the dictionary.