TeDeSm
asked on
Objects - How to add additional property in Class
I have the following code for a Customer object and would like to add additional properties. In this instance I would like to add IDCustomer. There is only one ID per customer. What would be the correct syntax for this?
I currently fill an array with customerArray.Add(New Customer(reader1("CompanyN ame"))).
I currently fill an array with customerArray.Add(New Customer(reader1("CompanyN
Public Class Customer
Inherits [Object]
Private custID As Long
Private custName As String = ""
Friend custOrders As New ArrayList()
Public Sub New(ByVal customername As String)
Me.custName = customername
End Sub
Public Property CustomerName() As String
Get
Return Me.custName
End Get
Set(ByVal Value As String)
Me.custName = Value
End Set
End Property
Public ReadOnly Property CustomerOrders() As ArrayList
Get
Return Me.custOrders
End Get
End Property
End Class 'End Customer class
Public Class Order
Inherits [Object]
Private ordID As String
Public Sub New(ByVal orderid As String)
Me.ordID = orderid
End Sub 'New
Public Property OrderID() As String
Get
Return Me.ordID
End Get
Set(ByVal Value As String)
Me.ordID = Value
End Set
End Property
End Class ' End Order class
ASKER
Thanks for the help.
I am specifying my array Private customerArray As New ArrayList() and filling it with
customerArray.Add(New Customer(reader1("CompanyN ame")))
I need this array to hold IDCustomer as well as the CustomerName, how do I set both for each array entry?
I am specifying my array Private customerArray As New ArrayList() and filling it with
customerArray.Add(New Customer(reader1("CompanyN
I need this array to hold IDCustomer as well as the CustomerName, how do I set both for each array entry?
Dim cust as New Customer(reader1("CompanyN ame"))
cust.CustomerID =reader1("CustomerID")
customerArray.Add(cust)
cust.CustomerID =reader1("CustomerID")
customerArray.Add(cust)
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Great solution, thanks
Open in new window