Thursday, 19 September 2013

Returning results from array that contains two types of results

Returning results from array that contains two types of results

Hello I'm trying to retrun array type named ZverejnenyUcetType but the
issue is that this array might contain two types : StandartniUcetType and
NestandardniUcetType.
So the issue is when I try to return the array like this:
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));
}
}
I get following exception: unable to cast object of type
RozhraniWSDL.NestandardniUcetType to type RozhraniWSDL.StandardniUcetType.
NestandardniUcetType contains only one item - cislo
StandartníUcetType have 3 items- predcislo, cislo, kod banky
Here is an image of the array:

I thought that the solution might be to determinate which of the result
are of type StandartniUcetType and which are NestandardniUcetType.
I would like to ask if this is possible to do?
I found this solution more common.
Thank you for your time.

No comments:

Post a Comment