O'Reilly logo

Visual C#® 2012: How to Program, Fifth Edition by Harvey Deitel, Paul Deitel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

10.6. Default and Parameterless Constructors

Every class must have at least one constructor. Recall from Section 4.10 that if you do not provide any constructors in a class’s declaration, the compiler creates a default constructor that takes no arguments when it’s invoked. In Section 11.4.1, you’ll learn that the default constructor implicitly performs a special task.

The compiler will not create a default constructor for a class that explicitly declares at least one constructor. In this case, if you want to be able to invoke the constructor with no arguments, you must declare a parameterless constructor—as in line 12 of Fig. 10.5. Like a default constructor, a parameterless constructor is invoked with empty parentheses. The Time2 parameterless ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required