Enum with decimal values or some like this
c#, combobox, enums, winforms
Solution
A dictionary may be a good choice.
`Dictionary<string,decimal>` could be a good candidate - letting you name the values.
var values = new Dictionary<string,decimal>();
values.Add("Value1", 0m);
values.Add("Value2", 0.5m);
values.Add("Value3", 1m);
This can be wrapped in a class so you only expose a getter by index, instead of the whole `Dictionary<TKey,TValue>` interface.
Problem
Basically I want to define an enum with decimal values but this is not possible. An alternative is: ``` public static class EstadoRestriccion { public const decimal Valur1 = 0; public const decimal Value2 = 0.5M; public const decimal Value3 = 1; }; ``` But I need add these constants in a combobox where the options to display should be the name of constants and `SelectedItem` should return the value (0, 0.5M, 1) or some like these. I know that it is possible but it is ugly. With an enum I can do this easly: `comboBox.DataSource = Enum.GetValues(typeof(MyEnum));` What is the best way to simulate an enum with my requirements?