Skip to content

Instantly share code, notes, and snippets.

@hperantunes
Created October 4, 2016 12:44
Show Gist options
  • Save hperantunes/60954dee5a859fdd72bc65f795a785d4 to your computer and use it in GitHub Desktop.
Save hperantunes/60954dee5a859fdd72bc65f795a785d4 to your computer and use it in GitHub Desktop.
public static class DictionaryExtension
{
public static TValue GetValueOrDefault<TKey, TValue>(this Dictionary<TKey, TValue> dictionary, TKey key) where TValue : class
{
TValue value;
return dictionary.TryGetValue(key, out value)
? value
: default(TValue);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment