October 2008
Beginner to intermediate
680 pages
16h 48m
English
As we get deeper into some of the features of C# we've been passing over until now, we'll need to take another look at constructors. We learned in Chapter 4 that when we instantiate a brand-new object with the new operator, we're creating a "bare bones" object with essentially empty fields (each field will be initialized to 0, null, or whatever is appropriate for a given field type, as discussed earlier). You also learned that if you want to create an object in a more intelligent fashion—that is, to do more elaborate things when the object is first created—you need to declare a constructor.
By way of review, a constructor
Has the same name as the class
Has no explicit return type because it really has a default
Read now
Unlock full access