Is there any difference between using .GetValueOrDefault(0) and If(variable, 0) with nullable types?
- by burlmd
Is there any difference between the 2 methods below for calculating c ... specifically boxing/unboxing issues?
Dim a As Integer? = 10
Dim b As Integer? = Nothing
Dim c As Integer
' Method 1
c = If(a, 0) + If(b, 0)
' Method 2
c = a.GetValueOrDefault(0) + b.GetValueOrDefault(0)