B
Bob
Hi,
I found this code here below (about cartitems and shoppingcart) and I have
two questions about sub New().
In the first class CartItem, there is two times sub New():
Public Sub New()
End Sub
and
Public Sub New(ByVal ProductID As Integer, ByVal ProductName As String, ...)
_productID = ProductID
_productName = ProductName
...
End Sub
In the second class WroxShoppingCart, there is one time sub New():
Public Sub New()
_items = New List(Of CartItem)
_dateCreated = DateTime.Now
End Sub
My questions are:
1) why an empty sub New() in class CartItem
2) why are there parameters defined in sub New() of class CartItem and not
in sub New() of class WroxShoppingCart?
Thanks
Bob
Part of code: (hopely this is enough)
---------------
Public Class CartItem
Private _productID As Integer
Private _productName As String
...
Public Sub New()
End Sub
Public Sub New(ByVal ProductID As Integer, ByVal ProductName As
String, ...)
_productID = ProductID
_productName = ProductName
...
End Sub
Public Property ProductID() As Integer
Get
Return _productID
End Get
Set(ByVal value As Integer)
_productID = value
End Set
End Property
....
End Class
Public Class WroxShoppingCart
Private _dateCreated As DateTime
Private _lastUpdate As DateTime
Private _items As List(Of CartItem)
Public Sub New()
_items = New List(Of CartItem)
_dateCreated = DateTime.Now
End Sub
End Class
I found this code here below (about cartitems and shoppingcart) and I have
two questions about sub New().
In the first class CartItem, there is two times sub New():
Public Sub New()
End Sub
and
Public Sub New(ByVal ProductID As Integer, ByVal ProductName As String, ...)
_productID = ProductID
_productName = ProductName
...
End Sub
In the second class WroxShoppingCart, there is one time sub New():
Public Sub New()
_items = New List(Of CartItem)
_dateCreated = DateTime.Now
End Sub
My questions are:
1) why an empty sub New() in class CartItem
2) why are there parameters defined in sub New() of class CartItem and not
in sub New() of class WroxShoppingCart?
Thanks
Bob
Part of code: (hopely this is enough)
---------------
Public Class CartItem
Private _productID As Integer
Private _productName As String
...
Public Sub New()
End Sub
Public Sub New(ByVal ProductID As Integer, ByVal ProductName As
String, ...)
_productID = ProductID
_productName = ProductName
...
End Sub
Public Property ProductID() As Integer
Get
Return _productID
End Get
Set(ByVal value As Integer)
_productID = value
End Set
End Property
....
End Class
Public Class WroxShoppingCart
Private _dateCreated As DateTime
Private _lastUpdate As DateTime
Private _items As List(Of CartItem)
Public Sub New()
_items = New List(Of CartItem)
_dateCreated = DateTime.Now
End Sub
End Class