我有一个简单的功能:
public string getType(object obj) {
Type type = obj.getType();
return type.FullName;
}
如果您在运行时创建的字符串对象上使用此函数,该函数将返回“System.RuntimeType”...
但它应该返回“System.String”...
如果你这样称呼它 -
string a = "";
string type = getType(a);
它会返回System.String
但如果你这样打电话——
string a = "";
string type = getType(a.GetType());
然后它会返回System.RuntimeType
另外,还有小typo
在你的方法中 -
Type type = obj.getType();
应该Type type = obj.GetType();
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)