0

I have an enum in C#:

public enum StatusEnum
    {
        [Display(Name = "It's Active")] 
        Active = 1,
        Deleted = 2
    }

I want to convert string to this enum, so I can use this code:

var x = Enum.TryParse("Active", out StatusEnum se);

this return true, and it's ok, but my problem is when I tried to convert the display name string:

var x = Enum.TryParse("It's Active", out StatusEnum se);

this does not work for me, what can I do?

MickyD
  • 14,343
  • 6
  • 43
  • 67
user10391869
  • 141
  • 1
  • 2
  • 7
  • 3
    Does this answer your question? [Enum value from display name](https://stackoverflow.com/questions/33225729/enum-value-from-display-name) – vivek nuna Oct 10 '21 at 11:46

0 Answers0