How can I create an enum using numbers?
- by Jordan S
Is it possible to make an enum using just numbers in C#? In my program I have a variable, Gain, that can only be set to 1, 2, 4, and 8. I am using a propertygrid control to display and set this value. If I were to create an enum like this...
private enum GainValues {One, Two, Four, Eight}
and I made my gain variable of type GainValues then the drop-down list in the propertygrid would only show the available values for the gain variable. The problem is I want the gain values to read numerically an not as words. But I can not create an enum like this:
private enum GainValues {1,2,4,8}
So is there another way of doing this? Perhaps creating a custom type?