将字符串转换为Type.GetType [英] Convert string to Type.GetType
本文介绍了将字符串转换为Type.GetType的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在上一门课.并尝试使用Type.GetType
创建实例对象.我的字符串是:
Hi,
I am making a bll class. and trying to create a instance object with Type.GetType
. My string is :
V2.PaidBLL.Reports.ReportRequests, V2.PaidBLL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
出现在str中.
代码是:
it comes in str.
code is:
Type t = Type.GetType(str);
,但它不起作用.
谢谢
Kuldeep Dwivedi
but it is not not working.
Thanks
Kuldeep Dwivedi
推荐答案
您没有正确使用该方法.Type.GetType
接受要获取的ypou类型的名称,因此您应该这样做:
You''re not using the method correctly.Type.GetType
accepts the name of the type ypou want to get, so you should be doing it like this:
Type myType = Type.GetType("System.String");
我认为您可能想做的是:
What I think you may be trying to do is this:
Type myType = str.GetType();
编辑(回答您的回答)=========================
您无法创建类型的实例.
EDIT (to answer your response) ==========================
You can''t create an instance of a type.
这篇关于将字符串转换为Type.GetType的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文