0

I have enum:

public enum AlertSubject
    {
        TouristVisa = 1,
        CarDamagene = 2,
        RentalForceClose = 3,
        CarAccident = 4
    }

how to get key like a string? I mean "1" for AlertSubject.TouristVisa

Mikhail Kostiuchenko
  • 9,121
  • 4
  • 15
  • 28

1 Answers1

2

You can use corresponding string format:

var s = AlertSubject.TouristVisa.ToString("d");

Enumeration format strings:

D or d. Displays the enumeration entry as an integer value in the shortest representation possible.

Guru Stron
  • 102,774
  • 10
  • 95
  • 132