Skip to content

Instantly share code, notes, and snippets.

@robfe
Last active August 29, 2015 14:08
Show Gist options
  • Save robfe/f81a85ff9430fe5ad188 to your computer and use it in GitHub Desktop.
Save robfe/f81a85ff9430fe5ad188 to your computer and use it in GitHub Desktop.
public static TValue GetValueOrDefault<TKey, TValue> (this Dictionary<TKey, TValue> d, TKey key, TValue defaultValue = default(TValue))
{
TValue value;
return d.TryGetValue(key, out value) ? value : defaultValue;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment