Can Enum contains other Enum elements along with its own elements ?
public enum CardSuit
{
spades,
hearts,
diamonds,
clubs
}
public enum GameSuit
{
spades, // These are
hearts, // the same
diamonds, // " CardSuit "
clubs, // elements
suns // " GameSuit " special element
}
Can we include CardSuit in GameSuit without redundant retyping same elements ?
Sadly no, there’s no good solution for what you want using enums. There are other options you can try, such as a series of
public static readonlyfields of a particular “enum-like” type:In practice, this can work mostly as well, albeit without
switchstatement support. Usage might be like: