查看泛型的IL

我们在开发中经常用到泛型,下面一起通过IL来查看泛型背后做了那些工作

示例代码

示例代码如下:

using System;
 
namespace MyCollection
{
    public class GenericExample
    {
        public static T GetT<T>(T value)
        {
            return value;
 
        }
        public static void Main(string[] args)
        {
            int a = GetT(3);
            string str = GetT("I'am String");
            Console.WriteLine("value1:{0}\t Value2:{1}",a,str);
        }
    }
}

相关文章: