Hi I have this enum currently
[Serializable]
public enum Country
{
US = 1,
Canada = 2,
}
When I usually get the integer from the database I convert it to the enum using
(Country) Convert.ToInt32("1")
I now have 2 sub regions in US and Canada, 1 & 2 for US and 3&4 for canada. So when I do
(Country) Convert.ToInt32("1") or (Country) Convert.ToInt32("2") i should get the enum to be US. and for 3 & 4 Canada. How do i implement this?
[Serializable]
public enum Country
{
US = 1,2
Canada = 3,4
}
Something like this. This is probably not right but just to give you an Idea.
Ah I just used a function instead of directly typecasting. Far more easier than to implement something entirely different. I already have lot of code running on this so cant change it much but here is what I did.