how may i use 0,1,8,18 in a class at public enum statement
i tried public enum {'0','1','8','18'} //identifier excpected error
and i tried public enum {"0","1","8","18"} //Still error
what must i do, what is the problem?
Loading
Serban CosminPosted Jun 8, 2010, 8:46 AM
You can try this:
enum Kdv : int
{
first = 0,
second = 1,
third = 8,
fourth = 18
}
and in your code you need to conver the enum fields to ints like this :
int myValue = (int) Kdv.first;
You can then convert it to a string or do whatever you like with it.
Hope this helps.
yaman basPosted Jun 7, 2010, 7:05 PM
sory i forgot the enumname, the orginal code is:
public enum Kdv {0,1,8,18}
0,1,8,18 is listing in a combobox, that s why can not use like first=0,second=1......
the problem is: this is a special propertygrid for wince component's combobox. So i have to use it like this because developer wrote this code like this. i tried what you say and after that in combobox there was "first,second,third" sentences but i want to show 0,1,8,18
Roy SPosted Jun 7, 2010, 6:24 PM
public enum enumName { first, second }
This will create an enum with first and second in it (first would be 0 and second 1)
public enum enumName { first = 8, second }
Here first will be 8 and second 9
public enum enumName { first = 8, second = 18 }
first = 8 and second 18, so to get it with 0, 1, 8, 18:
public enum enumName { first, second, third = 8, fourth = 18 }
You'll have to think up a name for your enum (enumName) and the members of it (first, second ...)