Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static class DictionaryExtensions
- {
- [DebuggerHidden]
- public static TValue GetValue<TKey, TValue>(this IDictionary<TKey, TValue> source, TKey key) {
- if(source == null) {
- throw new ArgumentNullException("source");
- }//if
- TValue value;
- if(!source.TryGetValue(key, out value)) {
- const string Format = "Key \"{0}\" does not found in a dictionary.";
- var message = String.Format(Format, key);
- throw new KeyNotFoundException(message);
- }//if
- return value;
- }
- // …
- }
Advertisement
Add Comment
Please, Sign In to add comment