Skip to main content
Edited in lieu of comments.
Source Link
Adam Houldsworth
  • 64.8k
  • 11
  • 161
  • 190

Enums cannot inherit from strings. In code you do not need to be concerned with the language of the code, so your enum can simply contain the relevant states.

Looks like what you need is a utility method to convert the enum value to the relevant string representation - simply make a method for this.

EDIT: when you use an enum to switch on cases, but need further information per enumerated value, I tend to drop the enum and create a host of static references and use those in the check instead. This reference can be a class wrapping an enum value, which could then expose helpful titles or descriptions.

Enums cannot inherit from strings. In code you do not need to be concerned with the language of the code, so your enum can simply contain the relevant states.

Looks like what you need is a utility method to convert the enum value to the relevant string representation - simply make a method for this.

Enums cannot inherit from strings. In code you do not need to be concerned with the language of the code, so your enum can simply contain the relevant states.

Looks like what you need is a utility method to convert the enum value to the relevant string representation - simply make a method for this.

EDIT: when you use an enum to switch on cases, but need further information per enumerated value, I tend to drop the enum and create a host of static references and use those in the check instead. This reference can be a class wrapping an enum value, which could then expose helpful titles or descriptions.

Source Link
Adam Houldsworth
  • 64.8k
  • 11
  • 161
  • 190

Enums cannot inherit from strings. In code you do not need to be concerned with the language of the code, so your enum can simply contain the relevant states.

Looks like what you need is a utility method to convert the enum value to the relevant string representation - simply make a method for this.