Loading ...

Find Enum Name from Value | CodeAsp.Net

Find Enum Name from Value

 /5
0 (0votes)

Here I have discuses find name of Enum from Enum value. I have a Enum like:

public enum EnumName
{
    Vijendra=1,
    Singh=2,
    Shakya=3
}



I have the value of this Enum in my database table, when I fetch that value from database then we want to show this value as Enum name. For example in my database there is 2 when I retrieve it from database then I want to show it “Singh” instead of 2.I have done this as follows:

int enumValue = 2//suppose this value is retrieve from databse

string strName = ((EnumName)enumValue).ToString()

strName have the Enum name which have value 2.

 




Comments (no comments yet)

  • :*
  • :*
  • :
 *

Top Posts