May 2010
Intermediate to advanced
1752 pages
41h 17m
English
C# supplies a this keyword that provides access to the current class instance. One possible use of the this keyword is to resolve scope ambiguity, which can arise when an incoming parameter is named identically to a data field of the type. Of course, ideally you would simply adopt a naming convention that does not result in such ambiguity; however, to illustrate this use of the this keyword, update your Motorcycle class with a new string field (named name) to represent the driver's name. Next, add a method named SetDriverName() implemented as follows:
class Motorcycle { public int driverIntensity; // New members to represent the name of the driver. public string name; public void SetDriverName(string name) { ...