X hits on this document

PDF document

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

251 views

0 shares

0 downloads

0 comments

30 / 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:

Visual Basic:

Public Sub New(ByVal make As String, _ ByVal model As String, _ ByVal elapsedMileage As Integer) m_make = make m_model = model m_elapsedMileage = elapsedMileage End Sub

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

Visual Basic:

myCar = New Car("Nissan",

"Altima", 31000)

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



Document info
Document views251
Page views251
Page last viewedSat Jan 21 11:42:11 UTC 2017
Pages73
Paragraphs821
Words15988

Comments