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
There have been a good amount of answers on this already however I will offer another solution. If you want your control to show an actual number as opposed to the english word for the number in your control you can use data annotations.
using System.ComponentModel.DataAnnotations;
private enum GainValues
{
[Display(Name = "1")]
One,
[Display(Name = "2")]
Two,
[Display(Name = "4")]
Four,
[Display(Name = "8")]
Eight
}
This is useful anywhere in your program where you want to use a friendly name as opposed to a member's actual name.