✅ why is the code so short?
so i have a piece of code:
thats a whole file and i dont know why it is so short, its in a folder called "Enums" and in file called "UserStatus", im providing a screenshot for better understanding of the whole project, but for example the file "SampleInterests" has all of this:
so why is the 1st file different from the 2nd one, can someone explain? why is the 2nd one in a class but the 1st one not?

24 Replies
please mention when reply so i can see
@mich4s because one is an enum and one is a list of strings
so enum just doesnt need anything
and a list needs a class?
I'm not really sure I understand the question.
there's not really a meaningful comparison you can make between them
Do you know what an enum is?
yeah
what is it
idk how to say it in english but its basically a set of values like in my example active is 0 cuz thats default starting value, inactive is 1 and suspended is 2
we usually used it in switch statements
right
it's a set of named constants
what's a list?
If you're asking why dedicate an entire source code file to a tiny enum, the answer is that you don't have to do that. C# used to have a pretty heavily followed convention of "one file per type" but I think people have since realized that's a bit silly.
idk how to explain it
like a dynamic data storage
of the same type
in my example string
no set length of the list
its similar to an array if i remember correctly
pretty much
so what's your question?
"why is the enum so short" well, because it can be
okay
so what about the 2nd file
why does it need a class
why does what need a class
my list
C# does not have true global state. Everything is attached to a class.
^
If you want a list of something it has to be part of some class somewhere.
okay
"everything" meaning everything that is not itself a type, which an enum is
If you are confusd why this is a valid C# program:
...when there is no class to be seen, that's because the compiler will generate one for you. It's special and only applies to the Main method entry point of your program.
okay thanks
Unknown User•3w ago
Message Not Public
Sign In & Join Server To View