I have an enum of the following structure:
public enum DType
{
LMS = 0,
DNP = -9,
TSP = -2,
ONM = 5,
DLS = 9,
NDS = 1
}
I’m using this enum to get the names and the values.
Since there is a requirement to add more types, I need to read the type and the values from an XML file. Is there any way by which I can create this enum dynamically from XML file so that I can retain the program structure.
Probably, you should consider using a
Dictionary<string, int>instead.If you want to generate the
enumat compile-time dynamically, you might want to consider T4.