2

我已经很天真地使用了一段时间了,实际上并没有对此了解太多,但基本上它是:

Private _SomeFieldDate As DateTime?

或者...

Private _SomeFieldInt As Int32?

我意识到最后的问号允许为字段分配一个Null或更确切地说是Nothing值的定义,但是这里到底发生了什么,这个问号的术语是什么?

(PS:我确实尝试在 SO 上查找此内容,但找不到;如果以前已发布过,那么您介意在答案中弹出该帖子的链接吗?)

4

2 回答 2

3

它被称为可为空的,问号是缩写

Nullable<T>

有关msdn 的更多信息

于 2013-10-08T08:22:27.613 回答
1

Primitive types such as integers and booleans cannot generally be null, but the corresponding nullable types (nullable integer and nullable boolean, respectively) can also assume the NULL value. NULL is frequently used to represent a missing value or invalid value, such as from a function that failed to return or a missing field in a database, as in NULL in SQL.

Source : http://en.wikipedia.org/wiki/Nullable_type

Nullable types in C# - http://msdn.microsoft.com/en-us/library/vstudio/1t3y8s4s.aspx

于 2013-10-08T08:22:06.337 回答