Constant variables in C#

The variables whose values do not change during execution are called as constants.
Suppose if you have some information such as how many students in the your class or how many states in your country etc. these information cannot be change in your program then you can be made unmodifiable by using const keyboard during initializing.

See the following example:

const int StatesCount = 45;
const string MyName = “AuthorCode”;

Constant variables can be initialized using an expression see this:

const int price = 20;
const int quantity = 10;
const int total = price * quantity;

You can not use non constant variables in expresson see this
int price = 20;
const int quantity = 10;
const int total = price * quantity; //Errro :The expression being assigned to ‘total’ must be constant

Constant cannot be initialized within methods.