将int []转换为对象时,意外的运算符是/作为行为

Evg*_*ich 4 c#

有人可以解释为什么会这样吗?

var y = new int[]{1,2};

Console.WriteLine(y is uint[]); // false
Console.WriteLine(((object)y) is uint[]); // true
Run Code Online (Sandbox Code Playgroud)

spe*_*der 7

在c#中你不能转换int为a uint,所以第一次测试失败,因为它被编译为常量false.

然而,内部- > UINT投由CLR允许的.第二次检查不能由编译器推断,因此必须在运行时计算.当您躲过编译器检查时,CLR允许它.