I got a need for two exactly identical enums with different names
I can do
enum DoorStatus{Open,Closed,Locked,Broken};
enum WindowStatus{Open,Closed,Locked,Broken};
and will probably be bit easier to read.
but I’d rather not duplicate code
in C++ I’d do
typedef Door,Window;
what is the solution in C#?
and why have both you ask?
I got Application That Handles a Window
application that handles a Door.
I want the Window application developer to send me data using ‘WindowStatus’ enum
the ‘Door’ guy use ‘DoorStatus’ enum.
I believe that user should know or care I got other devices that can be abstracted similarly.
EDIT: used
enum HatchStatus{Open,Closed,Locked,Broken};
using DoorStatus = HatchStatus;
using WndowStatus = HatchStatus;
EDIT2:
Error A using clause must precede all other elements defined in the namespace except extern alias declarations
🙁
If you just want an alias, you can use a
usingdirective: