| 123456789101112131415161718 |
- using System.Collections.Generic;
- namespace MonoGame.Extended.Collections
- {
- public static class DictionaryExtensions
- {
- public static TValue GetValueOrDefault<TKey, TValue>(this Dictionary<TKey, TValue> dictionary, TKey key)
- {
- return GetValueOrDefault(dictionary, key, default(TValue));
- }
- public static TValue GetValueOrDefault<TKey, TValue>(this Dictionary<TKey, TValue> dictionary, TKey key, TValue defaultValue)
- {
- TValue value;
- return dictionary.TryGetValue(key, out value) ? value : defaultValue;
- }
- }
- }
|