在下面的示例代码中,我尝试将Nullable(of T)用于DateTime,并且我想使用与Dimensions属性相同的List(Dimension).
Private _duedate As Nullable(Of DateTime)
Public Property DueDate() As Nullable(Of DateTime)
Get
Return _duedate
End Get
Set(ByVal value As Nullable(Of DateTime))
_duedate = value
End Set
End Property
Private _dimensions As List(Of Dimension)
Public Property Dimensions() As List(Of Dimension)
Get
Return _dimensions
End Get
Set(ByVal value As List(Of Dimension))
_dimensions = value
End Set
End Property
Run Code Online (Sandbox Code Playgroud)
如果我们可以请求任何帮助我们如何做到这一点将不胜感激.
谢谢.
有没有必要使用Nullable(Of T)的List(Of T).只需List(Of T)直接使用并使用Nothing无值状态.
基本功能Nullable(Of T)提供的是值类型具有无值状态.这个概念在C#中更清晰,其中没有值null和默认值之间存在语法差异default(T).在VB.Net中,虽然简单地Nothing表示没有引用类型的值和值类型的默认值.
| 归档时间: |
|
| 查看次数: |
980 次 |
| 最近记录: |