Thursday, 2 August 2012

Difference between readonly and constant

1. readonly and constant are two keywords
2. If you are using readonly keyword then the variable value can be assigned at the time of declaration otherwise in the constructor
3. where as in case of constant the variable value can only be assigned at the time of declaration not in the constructor
4.readonly variable can be accessed by the instance of a class where as in case of constant it is only accessed by the class name not by the instance of a class

No comments:

Post a Comment