Class DictionaryUtility
This utility class provides a set of concrete static methods for supporting the EnumerableUtility.
Inheritance
Namespace: Cuemon.Collections.Generic
Assembly: Cuemon.Core.dll
Syntax
public static class DictionaryUtility
Methods
| Improve this DocFirstMatchOrDefault<TKey, TValue>(IDictionary<TKey, TValue>, TKey[])
Returns the first TValue matching one of the specified keys in a System.Collections.Generic.IDictionary<TKey, TValue>, or a default value if the source contains no elements or no match was found.
Declaration
public static TValue FirstMatchOrDefault<TKey, TValue>(IDictionary<TKey, TValue> source, params TKey[] keys)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IDictionary<TKey, TValue> | source | The System.Collections.Generic.IDictionary<TKey, TValue> to return a matching |
| TKey[] | keys | A variable number of keys to match in the specified |
Returns
| Type | Description |
|---|---|
| TValue | default(TValue) if source is empty or no match was found; otherwise, the matching element in |
Type Parameters
| Name | Description |
|---|---|
| TKey | The System.Type of the key. |
| TValue | The System.Type of the value. |
Remarks
The default value for reference and nullable types is null.
FirstMatchOrDefault<TKey, TValue>(IDictionary<TKey, TValue>, TValue, TKey[])
Returns the first TValue matching one of the specified keys in a System.Collections.Generic.IDictionary<TKey, TValue>, or a defaultValue if the source contains no elements or no match was found.
Declaration
public static TValue FirstMatchOrDefault<TKey, TValue>(IDictionary<TKey, TValue> source, TValue defaultValue, params TKey[] keys)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IDictionary<TKey, TValue> | source | The System.Collections.Generic.IDictionary<TKey, TValue> to return a matching |
| TValue | defaultValue | The default value to return when |
| TKey[] | keys | A variable number of keys to match in the specified |
Returns
| Type | Description |
|---|---|
| TValue |
|
Type Parameters
| Name | Description |
|---|---|
| TKey | The System.Type of the key. |
| TValue | The System.Type of the value. |