Method TryGetValue
TryGetValue<TKey, TValue>(IDictionary<TKey, TValue>, TKey)
Attempts to retrieve a value with the sepcified key from the given collection and returns the result as a Maybe<T>. If the key is not found, an empty maybe is returned.
Declaration
public static Maybe<TValue> TryGetValue<TKey, TValue>(this IDictionary<TKey, TValue> source, TKey key)
Parameters
| Type | Name | Description |
|---|---|---|
| IDictionary<TKey, TValue> | source | The dictionary to retrieve a value from. |
| TKey | key | The key of the value to retrieve. |
Returns
| Type | Description |
|---|---|
| Maybe<TValue> | A Maybe<T> containing the retrieved value, or an empty Maybe<T> if the key was not found in the dictionary. |
Type Parameters
| Name | Description |
|---|---|
| TKey | The type of key stored in the dictionary. |
| TValue | The type of value stored in the dictionary. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Thrhwon if |