December 2017
Beginner
372 pages
10h 32m
English
As the name suggests, a property with a readonly access modifier cannot be modified after the value has been assigned to it. The value assigned to a readonly property can only happen at the time of variable declaration or in the constructor. We will look at constructors in Chapter 3, Sports News Combinator – Adding Features; here, we will see an example of a readonly property when initialized at the time of declaration:

In the above code, line 5 gives an error stating that property name is readonly, and cannot be an assigned value.
Read now
Unlock full access