public enum aa{ a1=1,a2=2,a3=6,...,a100=203}
How to get value like this
string att=GetFromDatabase("attribute"); //this return a1 or a2 ...
Enum.GetValue(att);
Get the value of an Enum To get the value of enum we can simply typecast it to its type. In the first example, the default type is int so we have to typecast it to int. Also, we can get the string value of that enum by using the ToString() method as below.
Yes you can programmatically index an enum, text, or menu ring.
Enum ValuesIf values are not assigned to enum members, then the compiler will assign integer values to each member starting with zero by default. The first member of an enum will be 0, and the value of each successive enum member is increased by 1. You can assign different values to enum member.
In TypeScript, enums, or enumerated types, are data structures of constant length that hold a set of constant values. Each of these constant values is known as a member of the enum. Enums are useful when setting properties or values that can only be a certain number of possible values.
Something like this should do the trick:
aa attEnum = (aa)Enum.Parse(typeof(aa), att);
Go to http://msdn.microsoft.com/en-us/library/system.enum.parse.aspx for more details.
Solution
string name = GetFromDatabase("attribute");
Enum.Parse(typeof(aa),name);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With