Show / Hide Table of Contents

Class AbpDictionaryExtensions

Extension methods for Dictionary.

Inheritance
System.Object
AbpDictionaryExtensions
Namespace: System.Collections.Generic
Assembly: Volo.Abp.Core.dll
Syntax
public static class AbpDictionaryExtensions : object

Methods

GetOrAdd<TKey, TValue>(IDictionary<TKey, TValue>, TKey, Func<TKey, TValue>)

Gets a value from the dictionary with given key. Returns default value if can not find.

Declaration
public static TValue GetOrAdd<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key, Func<TKey, TValue> factory)
Parameters
Type Name Description
IDictionary<TKey, TValue> dictionary

Dictionary to check and get

TKey key

Key to find the value

Func<TKey, TValue> factory

A factory method used to create the value if not found in the dictionary

Returns
Type Description
TValue

Value if found, default if can not found.

Type Parameters
Name Description
TKey

Type of the key

TValue

Type of the value

GetOrAdd<TKey, TValue>(IDictionary<TKey, TValue>, TKey, Func<TValue>)

Gets a value from the dictionary with given key. Returns default value if can not find.

Declaration
public static TValue GetOrAdd<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key, Func<TValue> factory)
Parameters
Type Name Description
IDictionary<TKey, TValue> dictionary

Dictionary to check and get

TKey key

Key to find the value

Func<TValue> factory

A factory method used to create the value if not found in the dictionary

Returns
Type Description
TValue

Value if found, default if can not found.

Type Parameters
Name Description
TKey

Type of the key

TValue

Type of the value

GetOrDefault<TKey, TValue>(ConcurrentDictionary<TKey, TValue>, TKey)

Gets a value from the dictionary with given key. Returns default value if can not find.

Declaration
public static TValue GetOrDefault<TKey, TValue>(this ConcurrentDictionary<TKey, TValue> dictionary, TKey key)
Parameters
Type Name Description
ConcurrentDictionary<TKey, TValue> dictionary

Dictionary to check and get

TKey key

Key to find the value

Returns
Type Description
TValue

Value if found, default if can not found.

Type Parameters
Name Description
TKey

Type of the key

TValue

Type of the value

GetOrDefault<TKey, TValue>(Dictionary<TKey, TValue>, TKey)

Gets a value from the dictionary with given key. Returns default value if can not find.

Declaration
public static TValue GetOrDefault<TKey, TValue>(this Dictionary<TKey, TValue> dictionary, TKey key)
Parameters
Type Name Description
Dictionary<TKey, TValue> dictionary

Dictionary to check and get

TKey key

Key to find the value

Returns
Type Description
TValue

Value if found, default if can not found.

Type Parameters
Name Description
TKey

Type of the key

TValue

Type of the value

GetOrDefault<TKey, TValue>(IDictionary<TKey, TValue>, TKey)

Gets a value from the dictionary with given key. Returns default value if can not find.

Declaration
public static TValue GetOrDefault<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key)
Parameters
Type Name Description
IDictionary<TKey, TValue> dictionary

Dictionary to check and get

TKey key

Key to find the value

Returns
Type Description
TValue

Value if found, default if can not found.

Type Parameters
Name Description
TKey

Type of the key

TValue

Type of the value

GetOrDefault<TKey, TValue>(IReadOnlyDictionary<TKey, TValue>, TKey)

Gets a value from the dictionary with given key. Returns default value if can not find.

Declaration
public static TValue GetOrDefault<TKey, TValue>(this IReadOnlyDictionary<TKey, TValue> dictionary, TKey key)
Parameters
Type Name Description
IReadOnlyDictionary<TKey, TValue> dictionary

Dictionary to check and get

TKey key

Key to find the value

Returns
Type Description
TValue

Value if found, default if can not found.

Type Parameters
Name Description
TKey

Type of the key

TValue

Type of the value

Back to top Powered by Volosoft