T
T
Timur Pokrovsky2020-06-06 13:36:19
C++ / C#
Timur Pokrovsky, 2020-06-06 13:36:19

Where is the best place to declare enums?

Let's say I have a class:

class SomeClass {
    public SomeEnum someEnum;
}

And where should I better declare the SomeEnum enum:
in class

class SomeClass {
    public SomeEnum someEnum;

    public enum SomeEnum {
        Red, Green, Blue
    }
}

or
outside of it?

class SomeClass {
    public SomeEnum someEnum;
}

enum SomeEnum {
    Red, Green, Blue
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Korotenko, 2020-06-06
@firedragon

If it refers only to the class, then inside it, if not, then outside

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question