What are constant and read-only members?
- Constant and read-only members specify that the value of the field or the local variable cannot be modified.
- A constant member can be declared using the keyword const, whereas a read-only member would be declared using the read-only modifier.
- The value of a const member is calculated at compile time. Therefore you cannot set a dynamic value to a const member.
- A read-only modifier specifies that the member can have its value set once only, and afterwards it becomes read- only. Therefore read-only can be used to set dynamic value.
No comments:
Post a Comment