using System.Collections.Generic;
namespace Subtext.Framework{
public static class DictionaryExtensions
{
public static TValue ItemOrNull<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key)
{
TValue value;
if(!dictionary.TryGetValue(key, out value))
{
return default(TValue);
}
return value;
}
}
}
|