Nullable type with inline if cannot work together?

Further to Damien’s answer, the clean way to do this is to not use Nothing, but New Double? instead:

Dim width As Double? = If(widthStr Is Nothing, New Double?, CDbl(widthStr))

And now that the type of the If expression is correct, this could be reduced to:

Dim width = If(widthStr Is Nothing, New Double?, CDbl(widthStr))

Leave a Comment