如下:

public static IList<T> Create<T>(Type type)
{
    if (type == typeof(List<T>))
    {
        return new List<T>();
    }
    if (type == typeof(T[]))
    {
        return new T[0];
    }
    throw new Exception();
}

 

相关文章:

  • 2021-12-24
  • 2021-06-30
  • 2022-12-23
  • 2021-06-03
  • 2022-02-12
  • 2022-12-23
  • 2021-09-11
猜你喜欢
  • 2022-01-07
  • 2022-12-23
  • 2022-12-23
  • 2021-11-01
  • 2021-12-09
  • 2021-06-24
  • 2021-11-22
相关资源
相似解决方案