Question

Are all Enum enumerations constants? Do they get converted to their value at compile-time, or at run-time?

Was it helpful?

Solution

They are constant. Yes, compile time.

Reference: http://msdn.microsoft.com/en-us/library/sbbt4032.aspx

From the intro:

The enum keyword is used to declare an enumeration, a distinct type that consists of a set of named constants called the enumerator list.

Under "Robust Programming":

Just as with any constant, all references to the individual values of an enum are converted to numeric literals at compile time. This can create potential versioning issues as described in Constants (C# Programming Guide).

OTHER TIPS

Enum values are constants, they cannot change.

Their values are fixed at compile time.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top