views:

545

answers:

2

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

+14  A: 

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).

Michael Haren
+4  A: 

Enum values are constants, they cannot change.

Their values are fixed at compile time.

AnthonyWJones