Megosztás a következőn keresztül:


DictionaryExtensions.GetOrAddNonNull<TKey,TValue> Method

Definition

Gets or adds the value associated with specified key.

public static TValue GetOrAddNonNull<TKey,TValue> (this System.Collections.Concurrent.ConcurrentDictionary<TKey,TValue> dictionary, TKey key, Func<TKey,TValue> valueFactory) where TValue : class;
static member GetOrAddNonNull : System.Collections.Concurrent.ConcurrentDictionary<'Key, 'Value (requires 'Value : null)> * 'Key * Func<'Key, 'Value (requires 'Value : null)> -> 'Value (requires 'Value : null)
<Extension()>
Public Function GetOrAddNonNull(Of TKey, TValue) (dictionary As ConcurrentDictionary(Of TKey, TValue), key As TKey, valueFactory As Func(Of TKey, TValue)) As TValue

Type Parameters

TKey

The type of the key parameter.

TValue

The type of the value parameter.

Parameters

dictionary
ConcurrentDictionary<TKey,TValue>

The dictionary containing the specified key.

key
TKey

The key whose value to get.

valueFactory
Func<TKey,TValue>

The value provider function.

Returns

TValue

The value associated with the specified key, if the key is found; otherwise the default value for the type of the value parameter.

Applies to