Difference between const and readonly
The read only keyword is different from the const keyword. A const field can only be initialized at the declaration of the field. A read only field can be initialized either at the declaration or in a constructor. Therefore read only field can have different values depending on the constructor used. Also, while a const field is a compile time constant but the read only field can be used for run time constants.
Comments
Post a Comment