C# Constants

Constants

If you don’t want others (or yourself) to overwrite existing values, you can add the const keyword in front of the variable type.

This will declare the variable as “constant”, which means unchangeable and read-only:

Example

const int myNum = 15;
myNum = 20; // error

Continue reading C# Constants