October 2008
Beginner to intermediate
680 pages
16h 48m
English
Chapter 4 introduced properties as a way to get or set the value of fields that have been given private access. Properties are used as if they were public data members, but behind the scenes they make use of a special type of method called accessors. In this section we will explore a few of the nuances of properties that make them even handier and more powerful.
By default, the get and set accessors of a property will have the same access as was given to the property itself. For example, the following property might be defined to access the id field of the Student class:
public string Id {
get {
return id;
}
set {
id = value;
}
}
In the previous example, the Id property is declared ...
Read now
Unlock full access