C# 为什么((int?)1.GetType()返回typeof(int)?

C# 为什么((int?)1.GetType()返回typeof(int)?,c#,.net,.net-4.0,nullable,C#,.net,.net 4.0,Nullable,可能重复: 我希望((int?)1).GetType()返回typeof(int?),但结果它返回typeof(int): 尽管如此,诸如((int?)1.HasValue之类的代码仍然可以很好地编译和运行 为什么将int强制转换为int?会返回int 请注意,如果我用一些int-变量替换常量(1),这也适用 bool a = ((int?)1).GetType() == typeof(int?); // a is false bool b = ((int?)1).GetType() ==

可能重复:

我希望
((int?)1).GetType()
返回
typeof(int?
),但结果它返回
typeof(int)

尽管如此,诸如
((int?)1.HasValue
之类的代码仍然可以很好地编译和运行

为什么将
int
强制转换为
int?
会返回
int

请注意,如果我用一些
int
-变量替换常量(
1
),这也适用

bool a = ((int?)1).GetType() == typeof(int?); // a is false
bool b = ((int?)1).GetType() == typeof(int); // b is true