首页 > Windows开发 > 详细

C# 字符串转类名

时间:2021-05-21 14:26:27      阅读:15      评论:0      收藏:0      [点我收藏+]

例如把 string str="xxxClassName ";转为 xxxClassName类并调用它的构造函数

Type t=str.GetType("  它的命名空间. "+str);

ConstructorInfo cti= t.GetConstructor(System.Type.EmptyTypes); //可以获得它的构造函数

xxxClassName x= (xxxClassName)cit.invoke(null)  //执行它的构造函数

C# 字符串转类名

原文:https://www.cnblogs.com/zienze/p/14793170.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!