As mentioned in Section 4.5, when a
GradeBook (Fig. 4.7) object is created, its instance variable
courseName is initialized to
null by default. This is also true of the
private instance variable that the compiler creates for the auto-implemented
CourseName property discussed in Section 4.8. What if you want to provide a course name when you create a
GradeBook object? Each class can provide a constructor that can be used to initialize an object of a class when the object is created. In fact, C# requires a constructor call for every object that’s created. The
new operator calls the class’s constructor to perform the initialization. The constructor call is indicated by the class name, followed by parentheses. ...