latest Post

Difference between Constant and Readonly in C#

Constant
Constant variables must be assigned value at compile time.
Once the value is assigned it cannot be changed.
It is static by default. So we need not define it as static.
It could be declared within functions.

Read Only
Read only variables are assigned at time of declaration or by the constructor of the class.
Read only are basically the run time constants.
By the time constructor exits the value must be set.
It is not static by default, so it can be declared static.

About Mallikarjun A

Mallikarjun A
Recommended Posts × +

0 comments:

Post a Comment