Constant Variables and Read Only Variables in C#

 

Constant Variables: A variable whose value cannot be modified once after declaration is a constant variable. Because it cannot modified after declaration, at the time of declaration only we need to assign value. The behaviour of a constant variable will be same as the behaviour if static variable, that is constants are also not associated with object of the class and maintains one only one copy. The only difference between constant variable and static variable is static variables can be modified and constant variables cannot be modified. 

Read Only Variable: Read only variables are the variables whose value cannot be modified once after initialization. So it is not required to initialize the variables at the time of declaration like constants. We can initialize the Read Only variables under a constructor. The behaviour of a Read-Only variable will be same as the behaviour if the instance variable i.e., they are initialized at the time of object creation as well as each time the object is created. The only difference between Read Only variables and instance variables os we can modify instance variables but not Read Only variables.