【发布时间】:2010-08-11 00:00:37
【问题描述】:
是否可以使用 GetType() 创建 List 或 IEnumerable。
// If T is Type of Contact I want to Return List<Contact>
Test(typeof(Contact));//return List<Type>
public static IEnumerable<T> Test<T>(T t)
{
return new List<T>(); //return List<Type>
}
【问题讨论】:
-
停下来想出一个合理的用例,你的问题就会消失。你想做什么?
标签: c# generics list reflection ienumerable