8
Possible Duplicate:
Nullable type is not a nullable type?
Why GetType returns System.Int32 instead of Nullable<Int32>?
I expected ((int?) 1).GetType() to return typeof(int?), but it turns out that it returns typeof(int):
bool a = ((int?)1).GetType() == typeof(int?); // a is false
bool b = ((int?)1).GetType() == typeof(int); // b is true
Still, code such as ((int?) 1).HasValue compiles and runs just fine.
Why does casting an int to int? return an int?
Note that this also holds true if I replace the constant (1) with some int-variable.