Answer:
No,we can not initialize or assign values to Read-only variables because they can only be used to initialize either in Variable Declaration or in Constructor only.
If we assign values in any method,then it will give us Compile-Time error as
"A readonly field cannot be assigned to (except in a constructor or a variable initializer)"
Asked In: Many Interviews |
Alert Moderator