How can I convert decimal? to decimal

后端 未结 5 1035
-上瘾入骨i
-上瘾入骨i 2021-02-02 05:31

may be it is a simple question but I\'m try all of conversion method! and it still has error! would you help me?

decimal? (nullable decimal) to decimal

5条回答
  •  攒了一身酷
    2021-02-02 06:06

    Try using the ?? operator:

    decimal? value=12;
    decimal value2=value??0;
    

    0 is the value you want when the decimal? is null.

提交回复
热议问题