sdr is my sqldatareader and I want to check that the curPrice value which is of type decimal is null.
inrec.curPrice = sdr.IsDBNull(7) ? (decimal?)null : sdr.
decimal?
indicates that it's a nullable decimal; you have to use the Value
property to get the actual value (if it exists, determined via HasValue
).
I'm assuming curPrice
is a non-nullable decimal, in which case you need to also figure out a better value to return than null
from the true side of your ternary operator.