代码清单3-12 获取泛型和已构造Type对象的各种方式

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string listTypeName = "System.Collections.Generic.List`1";
            Type defByName = Type.GetType(listTypeName);
            Type closedByName = Type.GetType(listTypeName + "[System.String]");
            Type closedByMethod = defByName.MakeGenericType(typeof(string));
            Type closeByTypeof = typeof(List<string>);
            Type defByTypeof = typeof(List<>);
            Type defByMethod = closedByName.GetGenericTypeDefinition();
            Console.WriteLine(closeByTypeof);
            Console.ReadKey();
        }
    }
}
原文地址:https://www.cnblogs.com/liuslayer/p/6957337.html