Understanding the null coalescing operator (??)

前端 未结 2 1715
攒了一身酷
攒了一身酷 2020-12-19 03:28

I have a custom WebControl which implements a .Value getter/setter returning a Nullable

It\'s a client-side filtered textbox

2条回答
  •  梦毁少年i
    2020-12-19 03:50

    Take a look at this similar question

    using coalescing null operator on nullable types changes implicit type

    why not just do

    decimal amount = uxTaxAmount.Value.HasValue ? uxTaxAmount.Value.Value : 0M
    

    This isn't the right answer to the original posters problems given recent edits and comments.

提交回复
热议问题