Nullbarer Typ mit Inline, wenn nicht zusammengearbeitet werden kann?

Mit folgendem Code:

Dim widthStr As String = Nothing

Das funktioniert -width zugeordnet istNothing:

Dim width As Nullable(Of Double)
If widthStr Is Nothing Then
  width = Nothing
Else
  width = CDbl(widthStr)
End If

Aber das tut nicht -width wird0.0 (obwohl es logisch identischer Code zu sein scheint):

Dim width As Nullable(Of Double) = If(widthStr Is Nothing, Nothing, CDbl(widthStr))

Warum? Kann ich irgendetwas tun, damit es funktioniert?

Antworten auf die Frage(2)

Ihre Antwort auf die Frage