zoukankan      html  css  js  c++  java
  • 代码清单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();
            }
        }
    }
  • 相关阅读:
    冲刺第二周第五天
    冲刺第二周第四天
    冲刺第二周第三天
    冲刺第二周第二天
    冲刺第二周第一天
    模拟内存警告
    iOS之单例
    ARC
    纹理
    ios消息
  • 原文地址:https://www.cnblogs.com/liuslayer/p/6957337.html
Copyright © 2011-2022 走看看