What's the difference between “bool” and “bool?”?

后端 未结 8 1885
栀梦
栀梦 2020-12-08 12:44

I use the \"bool\" type for variables as I was used to in C++, and I try to put the values of functions or properties I expect to be boolean into my variable. However I ofte

8条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-08 13:37

    Adding ? makes the type null-able. Which means you can do this:

    bool? x = null;
    

    And it would be totally OK.

提交回复
热议问题