Why can't I assign null to decimal with ternary operator?

后端 未结 6 852
故里飘歌
故里飘歌 2021-01-17 08:03

I can\'t understand why this won\'t work

decimal? compRetAmount = !string.IsNullOrEmpty(txtLineCompRetAmt.Text) 
    ? decimal.Parse(txtLineCompRetAmt.Text.R         


        
6条回答
  •  遥遥无期
    2021-01-17 08:20

    decimal? compRetAmount = !string.IsNullOrEmpty(txtLineCompRetAmt.Text) ?  
                              decimal.Parse(txtLineCompRetAmt.Text.Replace(",","")) : 
                              (decimal?)null;
    

提交回复
热议问题