您好我正在尝试重新运行名为的数组类型ZverejnenyUcetType
,但问题是该数组可能包含两种类型:StandartniUcetType
和NestandardniUcetType
。
所以问题是当我尝试像这样返回数组时:
string[] dic_vstup = new string[] { (line) };
RozhraniWSDL.InformaceOPlatciType[] dic_vystup;
RozhraniWSDL.rozhraniCRPDPH srv = new RozhraniWSDL.rozhraniCRPDPH();
StatusType status = srv.getStatusNespolehlivyPlatce(dic_vstup, out dic_vystup);
string abc = status.bezVypisuUctu.ToString(); // If it is already a string, then ToString not needed
for (int i = 0; i < dic_vystup.Length; i++)
{
RozhraniWSDL.InformaceOPlatciType info = dic_vystup[i];
for (int x = 0; x <= 3; x++)
{
file2.WriteLine((((RozhraniWSDL.StandardniUcetType)(info.zverejneneUcty[x].Item)).cislo) + "-"
+ (((RozhraniWSDL.StandardniUcetType)(info.zverejneneUcty[x].Item)).cislo) + "/"
+ (((RozhraniWSDL.StandardniUcetType)(info.zverejneneUcty[x].Item)).kodBanky));
}}
我得到以下异常:无法将类型的对象RozhraniWSDL.NestandardniUcetType
转换为 type RozhraniWSDL.StandardniUcetType
。
NestandardniUcetType
仅包含一项 -cislo
StandartníUcetType
有 3 个项目- predcislo
, cislo
,kod banky
这是数组的图像:
我认为解决方案可能是确定哪些结果是 type StandartniUcetType
,哪些是NestandardniUcetType
.
请问这样可以吗?
我发现这个解决方案更常见。
感谢您的时间。