Add GetValueOrDefault dictionary extension

This commit is contained in:
Claus Vium
2019-03-05 10:27:25 +01:00
parent bc00617df7
commit 318e0d4a24
2 changed files with 25 additions and 11 deletions

View File

@@ -0,0 +1,14 @@
using System.Collections.Generic;
namespace MediaBrowser.Common.Extensions
{
// The MS CollectionExtensions are only available in netcoreapp
public static class CollectionExtensions
{
public static TValue GetValueOrDefault<TKey, TValue> (this IReadOnlyDictionary<TKey, TValue> dictionary, TKey key)
{
dictionary.TryGetValue(key, out var ret);
return ret;
}
}
}