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);
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);
Solution
string name = GetFromDatabase("attribute"); Enum.Parse(typeof(aa),name);
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.
Use Enum.Parse
string att=GetFromDatabase("attribute"); //this return a1 or a2 ... Enum.Parse(typeof(aa), att);