Method TryGetFirstValueByKey
- Namespace
- DisCatSharp.Common
- Assembly
- DisCatSharp.Common.dll
TryGetFirstValueByKey<TKey, TValue>(Dictionary<TKey, TValue?>?, TKey, out TValue?)
Safely tries to extract the value of the first match where target key is found, otherwise null.
public static bool TryGetFirstValueByKey<TKey, TValue>(this Dictionary<TKey, TValue?>? dict, TKey key, out TValue? value) where TKey : notnull
Parameters
dictDictionary<TKey, TValue>The dictionary to use.
keyTKeyThe key to search for.
valueTValueThe value to get if succeeded.
Returns
- bool
Whether a value was found through the key.
Type Parameters
TKeyKey type of dictionary.
TValueValue type of dictionary.