I was busy this morning coding a specific piece of functionality and came across a need for enums nested inside of enums. What I want to do is have sub-options for options, eg.
Control X has properties:
- DockingLocation and
- DockedState
and DockingLocation has sub-options:
- Left
- Right
- Top and
- Bottom
Instead of creating two enums (or any other mechanism), I would have loved to have something like (syntax is debatable, I just want to demonstrate functionality):
public enum ControlXProperties
{
DockingLocation {Left, Right, Top, Bottom},
DockedState
}
Then using the enum in code could be something like (once again, syntax is debatable, I have two options in one):
switch (enumvarialbe)
{
case ControlXProperties.DockingLocation
switch (enumvariable)
{
case ControlXProperties.DockingLocation.Top
// do something
break;
default:
break;
}
break;
case ControlXProperties.DockingLocation.Left
// do somethng
break;
default:
break;
}
Now one has to create a class with properties and find other mechanisms to cross this.