Created
March 28, 2017 14:03
-
-
Save pietrom/73fa89837ada34b7f7abb34e842bf4fe 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 TOutput GetOrDefault<TOutput, TValue>(this IDictionary<string, TValue> self, string key, TOutput defaultValue) | |
where TOutput : TValue { | |
return self.ContainsKey(key) ? (TOutput)self[key] : defaultValue; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment