What is value
keyword here and how is it assigning the value to _num
? I\'m pretty confused, please give the description for the following code.
Properties
are the way you can READ, WRITE or COMPUTE values of a private field
or class variable
.
The set
or setter
inside a property
is used when the code assigns a value into the private field
or (class) variable
.
The value
keyword means simply "the thing that is being assigned".
public class StaffMember
{
private int ageValue;
public int Age
{
set
{
if ( (value > 0) && (value < 120) )
{ this.ageValue = value; }
}
get {
return this.ageValue;
}
}
}
//Rob Miles - C# Programming Yellow Book