我在使用 Vb.net 3.5 的类上有一个可为空的公共属性:
Public Property TicketCharge() As Nullable(Of Decimal)
Get
If _TicketCharge = Nothing Then
Return Nothing
Else
Return _TicketCharge
End If
End Get
Set(ByVal value As Nullable(Of Decimal))
If value.HasValue Then _TicketCharge = value
End Set
End Property
有一种分配值的方法。它工作正常,除非我尝试将值 0(零)分配给它。
If FundBuySell = "Exchange $" Or FundBuySell = "Exchange Shares" Then
TicketCharge = 0
Else
当我分配零然后检索它时,它显示属性 = 无。
我需要属性有时为空,有时为零。有人可以解释发生了什么吗?