May 2010
Intermediate to advanced
1272 pages
61h 18m
English
It’s not unusual to give a class the capability of exposing data but not of modifying such data. Continuing the example of the Person class, imagine you want to expose the FirstName and LastName properties plus a FullName property that returns the full name of the person. This property should be marked as read-only because only the FirstName and LastName properties should be editable, and FullName is the result of the concatenation of these two properties. You can therefore define a read-only property as follows:

The ReadOnly keyword marks properties as read-only. As you can easily understand, auto-implemented properties cannot ...
Read now
Unlock full access