【发布时间】:2009-03-26 20:04:31
【问题描述】:
我有一个这样的通用类:
public class Repository<T> {...}
我需要用一个字符串来实例化它...... 示例:
string _sample = "TypeRepository";
var _rep = new Repository<sample>();
我该怎么做?这可能吗?
谢谢!
【问题讨论】:
-
请注意,您不能在程序中引用 Repository
,因此 _rep 的类型必须是 object或所有 Repository的通用接口。
标签: c# .net reflection generics