屬性用於控制某個類的特性
Public Class CartItem
Private _productID As Integer
Private _productName As String
Private _productImageUrl As String
Private _quantity As Integer
Private _price As Double
Private _lineTotal As Double
Public Property ProductID() As Integer
Get
Return _productID
End Get
Set(ByVal value As Integer)
_productID = value
End Set
End Property
End Class
下面分解該代碼段並逐部分查看
Public Property ProductID() As Integer
接下來的代碼段允許讀取該屬性
Get
Return _productID
End Get
接下來寫出這些值
所有屬性的這種形式都相同
Public Property ProductName() As String
Get
Return _productName
End Get
Set(ByVal value As String)
_productName = value
End Set
End Property
[
From:http://tw.wingwit.com/Article/program/net/201311/14624.html