从入门型的偏名称的System.Type [英] Getting a System.Type from type's partial name
本文介绍了从入门型的偏名称的System.Type的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想获得的System.Type
只给出了字符串类型名称
。
举例来说,如果我有一个对象:
MyClass的ABC =新MyClass的();
然后我就可以说:
的System.Type类型= abc.GetType();
但是,如果我所拥有的是:
字符串的className =MyClass的;
解决方案
类型类型= Type.GetType(foo.bar.MyClass,foo.bar);
I want to get a System.Type
given only the type name in a string
.
For instance, if I have an object:
MyClass abc = new MyClass();
I can then say:
System.Type type = abc.GetType();
But what if all I have is:
string className = "MyClass";
解决方案
Type type = Type.GetType("foo.bar.MyClass, foo.bar");
MSDN. Make sure the name is Assembly Qualified.
这篇关于从入门型的偏名称的System.Type的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文