I have declared enum as below
public enum State
{
KARNATAKA = 1,
GUJRAT = 2,
ASSAM = 3,
MAHARASHTRA = 4,
GOA = 5
}
From external sources, I get the State values as either 1 or 2 or 3 or 4 or 5.
Based on the value i get, I need to look up this enum and get its string.
For Ex: If the input value is 1, I need to return KARNATAKA as string. Similarly, If the input value is 5, I need to return GOA as string.
Is there a easy way to get the string with out using CASE or IFELSE.
No comments:
Post a Comment