是否可空类型引用类型?类型

2023-09-02 21:10:01 作者:最愛妳的人是我

当我宣布一个 INT 为可为空

int? i=null;

确实这里成为一个引用类型?

Does i here become a reference type?

推荐答案

没有,可为空的是一个结构。正在发生的事情是,为空的结构有两个值。

No, a nullable is a struct. What is happening is that the nullable struct has two values.

的数据类型(INT对于int?,日期时间的日期时间?等)的值。 一个布尔值,如果数据类型值已设置它告诉(HasValue为属性)。

当您设置数据类型的值的结构变化hasVa​​lue的为真。

When you set the value of the data type the struct changes the HasValue to true.

什么是可空