X hits on this document

PDF document

“Beginning Visual C# 2005 Express Edition Video Series” - page 51 / 73

197 views

0 shares

0 downloads

0 comments

51 / 73

Overloading Constructors

Since a Constructor is simply a method, you can overload the Constructor. Recall from earlier in this chapter that overloading a method means that you can have different implementations of your method based on a different method signature.

I could create another Constructor that allows me to initialize the values as soon as I create an instance of the class:

C#:

public Car(string make, string model, int elapsedMileage)

{

make =

make;

_ model = _model; elapsedMileage =

elapsedMileage;

_

}

Then, this is how I would use that constructor when I create a new instance of the class:

C#:

myCar = new Car("Nissan",

"Altima", 31000);

Supplemental Readings for the Express Edition Videos Copyright © 2005 LearnVisualStudio.NET



Document info
Document views197
Page views197
Page last viewedFri Dec 09 15:54:05 UTC 2016
Pages73
Paragraphs821
Words15988

Comments