Created
October 4, 2016 12:44
-
-
Save hperantunes/60954dee5a859fdd72bc65f795a785d4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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