class A { enum TypeID = 1; } class B : A { enum TypeID = 2; } class C : A { enum TypeID = 3; } class D : B { enum TypeID = 4; } ... Could anybody shed some light on how to make these TypeIDs auto increment at compile time?