0

I have enum defined as below

public enum PatientRaceCodeType
{
    [StringValue("Question not asked")] 
    Q = 8,
    [StringValue("Unknown")]
    U = Q | B,
    [StringValue("Native Hawaiian OR Other Pacific Islander")]
    P = Q | D,
}

I need to get the string value for example if U it should return "unknown"

tried this:

Enum.GetName(typeof(testRaceCodeType), test.RaceCode) 

which is not working. test.Racecode has value U

René Vogt
  • 43,056
  • 14
  • 77
  • 99

1 Answers1

0

this code worked for me
(testRaceCodeType) Enum.Parse(typeof (testRaceCodeType), test.RaceCode)) .GetStringValue()