Invalid types in .net

Why

properties[5].PropertyType.GetGenericTypeDefinition() == 
   Type.GetType("System.Nullable`1")

      

is true and

properties[5].PropertyType.GetGenericTypeDefinition() ==
   Type.GetType("System.Nullable")

      

is false?

Properties[5]

is a field public Nullable<DateTime>

.

What does '1 after the

System.Nullable ' mean ?

0


a source to share


2 answers


"1" means the type is generic. Since it is possible to have a type called "Foo" as well as a type called "Foo", then there must be some internal way of differentiating the two types.



Since there is no generic type System.Nullable

, but you are using a generic type, your comparison to GetType ("System.Nullable") will always return false.

+5


a source


Nullable`1 is the real name of the class, which you know as Nullable <T> in C # (or Nullable (Of T) in VB.Net).



Nullable is a static class with a number of helper methods for using Nullable <T>.

+3


a source







All Articles