我有一個空屬性,我想返回一個空值。我如何在VB.NET中做到這一點?Nullable(Of T)的空值是什麼?
目前我使用這個解決方案,但我認爲可能有更好的方法。
Public Shared ReadOnly Property rubrique_id() As Nullable(Of Integer)
Get
If Current.Request.QueryString("rid") <> "" Then
Return CInt(Current.Request.QueryString("rid"))
Else
Return (New Nullable(Of Integer)).Value
End If
End Get
End Property
嗯,其實是的。我發現實際上Nothing沒有等同於C#null,而我認爲它僅用於查看對象是否被實例化。 – thomasb 2008-09-16 14:03:57