• 调用的方法里接收一个List<>类型的参数,里面是自定义的EC类, 我要通过反射构建这List对象


              public static object CreateGeneric(Type generic, Type innerType, params object[] args)
            {
                Type specificType = generic.MakeGenericType(new System.Type[] { innerType });
                return Activator.CreateInstance(specificType, args);
            }
            object genericList = CreateGeneric(typeof(List<>), typeof(EC));
     
     
    获取List<T>中T的类型
     
        public class MyClass
            {
            }
            Type t = typeof(List<MyClass>).GetGenericArguments()[0];
            Console.WriteLine(t.Name);
            //输出
             //MyClass
    bloodish 
  • 相关阅读:
    高精度A+B
    基本定积分求面积
    二进制算子集和
    linux命令
    Dubbo
    java 集合区别
    Java中Comparable和Comparator区别
    synchronized实现原理
    ThreadLocal 原理
    java volatile关键字
  • 原文地址:https://www.cnblogs.com/hedianzhan/p/8986937.html
Copyright © 2020-2023  润新知