5

Possible Duplicate:
Enum “Inheritance”

I've been trying to do something like inheritance in Enum. I wanted a base Enum with multiple values from different Enums.

the best approach will be answered below.

Community
  • 1
  • 1
Ruba
  • 867
  • 3
  • 11
  • 19
  • 7
    I wonder what is the reason to do something like this... – Pawel Nov 28 '12 at 07:19
  • In a video game, for example, you may have `enum AllClasses { Mage, Paladin, Warrior, King }` then you'd want to theoretically do something like`enum AllClassesAndKingTypes : { GoodKing, BadKing, NeutralKing }`. That's what I thought about immediately, which is why I found this post on Google. Enums would be used instead of strings for accurate typings, as game classes often get renamed in the future for whatever reason (esp in early production). Let's say GoodKing ends up being removed, it'd be easy to trace back where this was used. Let's say Paladin name changes. F2 > Rename > done. – dylanh724 Jul 31 '18 at 06:54

1 Answers1

5

Enum is a value type and consequently sealed, i.e. cannot be inherited. See also Enum “Inheritance”

Community
  • 1
  • 1
horgh
  • 17,918
  • 22
  • 68
  • 123