Created
July 15, 2016 15:31
-
-
Save jeremydmiller/8786b6d0caa2b58a00a7f530710bcbc0 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
/// <summary> | |
/// This is a big THANK YOU to the BCL for not hooking a brotha' up | |
/// This add will tell WHAT KEY you added twice. | |
/// </summary> | |
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