试图找到一个小谜团的底部。
我有以下 If 语句:
Dim myVal As Nullable(Of Guid)
myVal = If(vendor.Address.ID = Guid.Empty, Nothing, vendor.Address.ID)
myVal
莫名其妙的是,这里的最终值是Guid.Empty
。
如果我编写相同的代码如下:
Dim myVal As Nullable(Of Guid)
If(vendor.Address.ID = Guid.Empty) Then
myVal = Nothing
Else
myVal = vendor.Address.ID
End If
为什么有区别?