In this short tutorial, you will learn the key points of C# constants.
A constant is a variable whose value cannot be changed throughout its lifetime, and it is defined with the keyword
const string testStr = "This is a constant";
- Constants must be initialized when they are declared. And can never be overwritten after a value been assigned.
- The value of a constant must be computable at
compiletime. As the
compilerreplaces the variable with its values everywhere it is used.
- Constants are always implicitly