Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@angelovstanton
Created September 6, 2015 10:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save angelovstanton/4c98388069e6f9962067 to your computer and use it in GitHub Desktop.
Save angelovstanton/4c98388069e6f9962067 to your computer and use it in GitHub Desktop.
public static class DictionaryExtensions
{
public static TValue GetValueOrDefault<TKey, TValue>(this Dictionary<TKey, TValue> dic, TKey key)
{
TValue result;
return dic.TryGetValue(key, out result) ? result : default(TValue);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment