C# – In C# what is lifetime or lifespan of constant variable

cconst

In C# if i declare a constant variable is any memory allocated to it as it acts as a compile time replacement? How long is the variable's life?

Best Answer

Literal consts are compile time replacements. Section 14.16 in the spec I have handy:

A constant expression is an expression that shall be fully evaluated at compile-time.

Related Topic