反射根据类名动态生成对象

public T CreateObj<T>(string className) where T:class
{
Type type = Type.GetType(className);
return Activator.CreateInstance(type) as T;
}

 

posted @ 2020-09-21 01:21  小辉歌  阅读(291)  评论(0)    收藏  举报