c# - Enum with decimal values or some like this -


Actually I want to define a value with decimal values ​​but this is not possible. An alternative is:

  Public static class EstadoRestrician {public key point = 1; Mass cumulative decimal value 2 = 0.5 m; Public const decimal value 3 = 1; };   

But I need to add these constants to a combing box where the option should be the name of the constant to display the option and return the value to SelectedItem (0 , 0.5M, 1) or something like these I know that this is possible, but it's ugly.

With an enum I can do this easily: comboBox.DataSource = Enum.GetValues ​​(typeF (MyEnum));

can be a dictionary < P> dictionary & lt; String, decimals & gt; Can be a good candidate - you name the values.

  var value = new dictionary & lt; String, decimals & gt; (); value. Add ("value1", 0m); Values. Add ("value 2", 0.5 m); Values. Add ("value 3", 1 m);   

It can be wrapped in a class so that you can enter the full dictionary & Ttk; TKey, TValue & gt; Expose gates by index rather than interface only.

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -