Created
October 7, 2013 19:28
-
-
Save bitsprint/6873519 to your computer and use it in GitHub Desktop.
Dictionary Extensions
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 void SmartAdd<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key, TValue value) | |
| { | |
| try | |
| { | |
| dictionary.Add(key, value); | |
| } | |
| catch (ArgumentException e) | |
| { | |
| throw new ArgumentException("The key '{0}' already exists.".ToFormat(key), e); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment