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?
- Anybody can ask a question
- Anybody can answer
- The best answers are voted up and rise to the top
No memory is allocated since the value is put directly into code. The compiler places the constant in the assembly metadata, so the lifetime of the constant is the lifetime of the assembly it's in.