为什么泛型类型在函数定义中看起来像(!! T),在CIL中看起来是(!! 0).在某些情况下,泛型类型的参数看起来像(!0).隐藏的秘密是什么?或者为什么这样设计?
先感谢您.
下面是C#中的代码:
private static void Main(string[] args)
{
Test<int>();
TestList<int>(new List<int>{ 1, 2,3 }, 1, 2, 3, 4, 5, 6, 7,8);
Console.ReadKey();
}
private static void TestList<T>(List<T> list, T item, T t2, T t3, T t4, T t5, T t6, T t7, int t8)
{
Console.WriteLine(item == null);
Console.WriteLine("Collection contains {0}? {1}", item, list.Contains(item));
}
Run Code Online (Sandbox Code Playgroud)
和调用TestList的CIL代码:
IL_002e: call void BoxingAndUnboxing.Program::TestList<int32>(class [mscorlib]System.Collections.Generic.List`1<!!0>,
!!0,
!!0,
!!0,
!!0,
!!0,
!!0,
!!0,
int32)
Run Code Online (Sandbox Code Playgroud)
和函数定义的CIL代码:
.method private hidebysig static void TestList<T>(class [mscorlib]System.Collections.Generic.List`1<!!T> …Run Code Online (Sandbox Code Playgroud)