IDictionaryExtensionsAddOrGetTKey, TValue(IDictionaryTKey, TValue, TKey, FuncTKey, TValue) Method

Adds the specified key and value to the specified IDictionaryTKey, TValue if the key does not already exist, and returns the value.

Definition

Namespace: DevCase.Extensions.IDictionaryExtensions
Assembly: DevCase.net48 (in DevCase.net48.dll) Version: 6.0.0.0 (6.0)
XMLNS for XAML: Not mapped to an xmlns.
[EditorBrowsableAttribute(EditorBrowsableState.Always)]
public static TValue AddOrGet<TKey, TValue>(
	this IDictionary<TKey, TValue> sender,
	TKey key,
	Func<TKey, TValue> valueFactory
)

Parameters

sender  IDictionaryTKey, TValue
The source IDictionaryTKey, TValue.
key  TKey
The key to add.
valueFactory  FuncTKey, TValue
A function used to generate a value for the key.

Type Parameters

TKey
TValue

Return Value

TValue
The value.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IDictionaryTKey, TValue. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

See Also