What is the difference between Readonly and constant in C#
The only difference between both is in their intialization.
if u declare a constant field you must set the value before ntializing object.
but readonly you can declare it in constructor.
both cannot be altered once declared.
if u declare a constant field you must set the value before ntializing object.
but readonly you can declare it in constructor.
both cannot be altered once declared.
No comments:
Post a Comment