Is there any difference between type? and Nullable?

前端 未结 9 1191
礼貌的吻别
礼貌的吻别 2020-12-15 15:53

In C# are the nullable primitive types (i.e. bool?) just aliases for their corresponding Nullable type or is there a difference between th

9条回答
  •  既然无缘
    2020-12-15 16:18

    A bool is a value type, therefore it can't contain a NULL value. If you wrap any value type with Nullable<>, it will give it that ability. Moreover, access methods to the value change by additional properties HasValue and Value.

    But to the question: Nullable and bool? are aliases.

提交回复
热议问题