CIL unbox_any instruction - strange behavior
问题 .method public static void Test<class T>(object A_0) cil managed { // Code size 13 (0xd) .maxstack 1 .locals init (!!T V_0) IL_0000: ldarg.0 IL_0001: isinst !!T IL_0006: unbox.any !!T IL_000b: stloc.0 IL_000c: ret } // end of method DemoType::Test The equal C# code is: public static void Test<T>(object o) where T : class { T t = o as T; } My questions are: Why unbox.any been called? if you just do var a = father as child isinst intruction will call and no unbox.any, and If i'll remove the