16 lines
411 B
C#
16 lines
411 B
C#
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;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|