I m 通常在C#的家中,I m 在VB中研究业绩问题。 NET代码: 我想能够比较某种类型的缺省值(例如C# sdefault
关键词)。
public class GenericThing<T1, T2>
{
public T1 Foo( T2 id )
{
if( id != default(T2) ) // There doesn t appear to be an equivalent in VB.NET for this(?)
{
// ...
}
}
}
I was led to believe that Nothing
was semantically the same, yet if I do:
Public Class GenericThing(Of T1, T2)
Public Function Foo( id As T2 ) As T1
If id IsNot Nothing Then
...
End If
End Function
End Class
然后在<代码>T2上<>Integer<>/code>,id
值0
, 仍须通行证和 >的正体得到评价。 然而,如果我这样做的话:
Public Function Bar( id As Integer ) As T1
If id <> Nothing Then
...
End If
End Function
当时情况没有得到满足,没有评估尸体。