Class EnumDictionary<TEnum, TValue>
- Namespace
- Gamelogic.Extensions
- Assembly
- Gamelogic.Extensions.dll
Represents a dictionary with keys of an enumerated type.
[Version(4, 5, 0)]
[Serializable]
public class EnumDictionary<TEnum, TValue> : IReadOnlyDictionary<TEnum, TValue>, IReadOnlyCollection<KeyValuePair<TEnum, TValue>>, IEnumerable<KeyValuePair<TEnum, TValue>>, IEnumerable
Type Parameters
TEnumA type of enum. An error will be thrown if this type is not an enum type.
TValueThe value type. For the dictionary to be serializable, this type must also be serializable.
- Inheritance
-
EnumDictionary<TEnum, TValue>
- Implements
-
IReadOnlyDictionary<TEnum, TValue>IReadOnlyCollection<KeyValuePair<TEnum, TValue>>IEnumerable<KeyValuePair<TEnum, TValue>>
- Inherited Members
- Extension Methods
Remarks
This class differs from an ordinary dictionary
- it is serializable
- does not provide constant time access to elements
- it always has all values of the enum as keys
It is meant to be used with enums with a smallish number of elements. Because of the last property above, it can cause problems if the enum type used for keys changes. This can corrupt the dictionary. Keep the enum type stable, or inspect all serialized instances after changes have been made.
Constructors
- EnumDictionary()
Initializes a new instance of the EnumDictionary<TEnum, TValue> class.