.net中的可空类型

Jos*_*orp 0 .net c# .net-3.5

为什么

properties[5].PropertyType.GetGenericTypeDefinition() == 
   Type.GetType("System.Nullable`1")
Run Code Online (Sandbox Code Playgroud)

等于真实

properties[5].PropertyType.GetGenericTypeDefinition() ==
   Type.GetType("System.Nullable")
Run Code Online (Sandbox Code Playgroud)

等于假?

Properties[5]是一个public Nullable<DateTime>领域.

``1 after theSystem.Nullable`是什么意思?

Mat*_*ton 5

`1表示该类型是泛型类型.由于可能有一个名为"Foo"的类型以及一个名为"Foo"的类型,因此需要有一些内部方法来区分这两种类型.

由于存在非泛型System.Nullable类型,但您使用的是泛型类型,因此与GetType("System.Nullable")的比较将始终返回false.