I want to create a hierarchical enum that represents a type that I can pass as a parameter.
The data structure looks like this:
enum Cars
{
Ford { Corsair, Cortina, Galaxy, GT },
Ferrari { Testarossa, California, Enzo },
...
}
I wish to call a function with the following signature:
public void BuildCar(Cars car);
Like this:
BuildCar(Cars.Ferrari.Enzo);
Basically, I want to enforce the car/manufacturer relationship in the type.
I thought about answering this with extensions and/or
ICustomEnumstuff.Then I thought – is there anything really that bad with the following? 🙂
Your function still looks like:
Your call looks like: