Share via

Use Enum in Enum

Mahdi Elahi 36 Reputation points
2022-03-27T17:38:24.393+00:00

Hi. i want use enum in enum , for example:

CarEnum.Car1.Color
CarEnum.Car1.Tires

CarEnum.Car2.Speed
CarEnum.Car2.Fuel

public enum CarEnum{ Car1, Car2}

but how to add another enum in this enum ?

Developer technologies | C#
Developer technologies | C#

An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.

0 comments No comments

Answer accepted by question author

Viorel 127K Reputation points
2022-03-27T18:40:57.95+00:00

Try an alternative:

public static class CarEnum
{
    public enum Car1 { Colour, Tires };
    public enum Car2 { Speed, Fuel };
}

Consider namespaces too.

Was this answer helpful?


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.