KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
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.
Tags (comma-separated)
Save Edits
Cancel