Let’s assume we have an enumeration like shown below. I have
the integer value of the enumeration and I want to get the enumeration type.
DATATYPE_1 = 11,
DATATYPE_2 = 12,
DATATYPE_3 = 23,
DATATYPE_4 = 34,
DATATYPE_5 = 45,
DATATYPE_6 = 56,
DATATYPE_7 = 67,
DATATYPE_8 = 78
}
Cheers
Adam
public enum DataTypeCodes
{DATATYPE_1 = 11,
DATATYPE_2 = 12,
DATATYPE_3 = 23,
DATATYPE_4 = 34,
DATATYPE_5 = 45,
DATATYPE_6 = 56,
DATATYPE_7 = 67,
DATATYPE_8 = 78
}
Here is the code snippet to achieve this.
Int value = 23;
DataTypeCodes dt = (DataTypeCodes) value;
DataTypeCodes dt = (DataTypeCodes) value;
This should give me 'DATATYPE_3'.
Adam