13.9. Constructors, Revisited
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
Get Beginning C# 2008 Objects: From Concept to Code now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.