C#通过对象类型创建对象实例的代码

下边代码内容是关于C#通过对象类型创建对象实例的代码。

object[] paramObject = new object[] {};
object obj = Activator.CreateInstance(type, paramObject);





或者


string className = "MyType";
MyType myType = (MyType) Activator.CreateInstance(Type.GetType(className), new object[]{});




 

posted @ 2019-04-30 10:19  lpypg  阅读(2365)  评论(0)    收藏  举报