Creating an Object

Recall that a class is an abstract definition listing the functionality that is provided. In addition to properties and methods, classes contain constructors. A constructor is a special method that is used to create an instance of the class.

In a later section, “Calling an Object's Methods,” we'll discuss what, exactly, methods are. For now you can think of a method as a function or subroutine. Like functions and subroutines, a method is a means of encapsulating a number of program instructions and, again like functions and subroutines, can have zero or more parameters.

Constructors always have the same name as the class. For ...

Get SAMS Teach Yourself ASP.NET in 24 Hours 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.