This commit is contained in:
@@ -0,0 +1,15 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace SuccessfulCodeTools.Extensions
|
||||||
|
{
|
||||||
|
public static class ReadOnlyDictionaryExtensions
|
||||||
|
{
|
||||||
|
public static TValue GetValueOrDefault<TKey, TValue>(this IReadOnlyDictionary<TKey, TValue> dictionary, TKey key)
|
||||||
|
{
|
||||||
|
if(dictionary.TryGetValue(key, out TValue value))
|
||||||
|
return value;
|
||||||
|
|
||||||
|
return default;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user