Hi all,
I have a problem encapsulating a class within a class. It all seems to look okay but I get stuck in a loop when calling it eg.
Dim myCart As New Data.Cart
myCart.Items.Add("00000000-0000-0000-0000-000000000000", 1)
All I get is myCart.Items.Items.Items.Items.....
I'm obviously doing something wrong, can anyone help??!
TIA
I have a problem encapsulating a class within a class. It all seems to look okay but I get stuck in a loop when calling it eg.
Dim myCart As New Data.Cart
myCart.Items.Add("00000000-0000-0000-0000-000000000000", 1)
All I get is myCart.Items.Items.Items.Items.....
I'm obviously doing something wrong, can anyone help??!
TIA
VB.NET:
Namespace sgi.data
Public Class Cart
Public Class item
Private _productid As String = ""
Private _quantity As Integer = 0
Public Property productid() As String
Get
Return _productid
End Get
Set(ByVal value As String)
_productid = value
End Set
End Property
Public Property quantity() As Integer
Get
Return _quantity
End Get
Set(ByVal value As Integer)
_quantity = value
End Set
End Property
Public Sub New()
End Sub
Public Sub New(ByVal productid As String, ByVal quantity As Integer)
Me.productid = productid
Me.quantity = quantity
End Sub
End Class
Protected _item As List(Of item)
Public Sub New()
_item = New List(Of item)
End Sub
Public Class items
Inherits Cart
Public Sub Add(ByVal productid As String, ByVal quantity As Integer)
_item.Add(New item(productid, quantity))
End Sub
End Class
End Class
End Namespace