Skip to Content
Microsoft® Visual C#® .NET 2003 Kick Start
book

Microsoft® Visual C#® .NET 2003 Kick Start

by Steven Holzner
June 2003
Intermediate to advanced
624 pages
12h 41m
English
Sams
Content preview from Microsoft® Visual C#® .NET 2003 Kick Start

Creating Constructors

We've created objects using new like this: Customer customer = new Customer();. If you're an OOP programmer, you know those parentheses after Customer are there for a reason, because when you create an object from a class, you're using the class's constructor. A constructor is a special method that has the same name as the class and returns no value. It is used to initialize the data in the object you're creating. In C#, constructors are declared this way:

[attributes] [modifiers] identifier([formal-parameter-list])
[initializer] { constructor-body }

Here are the parts of this statement:

  • attributes (Optional)— Hold additional declarative information, as we'll see in Chapter 14.

  • modifiers (Optional)— The allowed modifiers ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Microsoft® .NET Kick Start

Microsoft® .NET Kick Start

Hitesh Seth

Publisher Resources

ISBN: 0672325470Purchase book