I'm experiencing unpredicted effects with nullables in VB.net. The object in question has a property defined:
Public Property Value As Int32?
When I try to coalesce the value using IIf
, I get a null exception
cmd.Parameters.AddWithValue("@HOValue", IIf(headOffice.Value.HasValue, headOffice.Value .Value, DBNull.Value))
In C#, I know there's no implicit conversion for nullables, hence you can't use ??
, but why is the first part of the IIf being evaluated in VB.NET?