方法无法返回值,错误:无法在 C#、ASP.NET 中转换类型 [英] method can't return value, Error: can not convert type in C#, ASP.NET
本文介绍了方法无法返回值,错误:无法在 C#、ASP.NET 中转换类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有应该返回一组数据的方法.但最后在返回数据时,错误显示为:无法将类型 'WebApplication1.Webrefernce13.DT_value[]' 转换为 'WebApplication1.Webrefernce13.DT_value"
I have method that should return a set of data. But at last when returning data then error shows like :"can not convert type 'WebApplication1.Webrefernce13.DT_value[]' to 'WebApplication1.Webrefernce13.DT_value"
public class InputHelp
{
public DT_Value Priority()
{
WebReference13.DT_SM_InputHelp_Request IncomingtypeReq = new WebReference13.DT_SM_InputHelp_Request();
WebReference13.DT_SM_InputHelp IncomingTypeResp;
WebReference13.SI_CreateSM_OBService _proxy1 = new WebReference13.SI_CreateSM_OBService();
CookieContainer cookie = new CookieContainer();
_proxy1.Credentials = new NetworkCredential("xxxx", "xxxxx"); // use credential to acess to the SAP system
_proxy1.CookieContainer = cookie;
IncomingtypeReq.Mode = "Create";
IncomingtypeReq.Language = "EN";
IncomingtypeReq.OptionalText1 = "ZLFN";
IncomingtypeReq.OptionalText2 = "";
IncomingtypeReq.WSCallID = "223424dgdf";
IncomingTypeResp = _proxy1.SI_GetInputHelp(IncomingtypeReq);
DT_Value[] ab=new DT_Value[10];
ab= IncomingTypeResp.Priority;
return ab; // error is here
}
如果你能在这个问题上帮助我,我将不胜感激.
I will be grateful if you can help me on this issue.
推荐答案
将您的方法签名更改为
public DT_Value[] Priority(){...}
还有
DT_Value[] ab=new DT_Value[10];
ab = IncomingTypeResp.Priority; //<-- something doesn't look right here.
如果 IncomingTypeResp.Priority
是 DT_Value[]
类型,那么你可以这样做
if IncomingTypeResp.Priority
is of type DT_Value[]
then you can just do
DT_Value[] ab = IncomingTypeResp.Priority;
这篇关于方法无法返回值,错误:无法在 C#、ASP.NET 中转换类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文