Cannot implicitly convert type 'decimal?' to 'decimal'.

前端 未结 4 906
南笙
南笙 2021-01-04 10:08

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.

4条回答
  •  一整个雨季
    2021-01-04 11:04

    either convert curPrice to nullable, or use .Value property of nullable types.

    If curPrice is a property of a class then

    public decimal? curPrice
    {
       get;
       set;
    }
    

提交回复
热议问题