.NET foreach, Classes and Arrays - accessing objects from arrays!

mikestoods

New Member
I have the following code

Code:
DEFINE VARIABLE objAddress          AS CLASS "IAddress".
DEFINE VARIABLE objConnection       AS CLASS "IConnection".
DEFINE VARIABLE objConnectionArray  AS CLASS "IConnection[]".

objAddress = NEW Address().
objConnectionArray = objAddress:connections.    /* This is an array containing "connections" - which are objects)
objConnection = UNBOX(objConnectionArray.GetValue(1)).

This obviously assumes there are 2 elements in the connections array.
However, I get the message back that "this cannot be unboxed".

In essence, I want to do a c# foreach to go around the array in progress, but not sure how to do this
In c# you would do something like...

Code:
foreach(IConnection __connection in _objAddress.connections)

Help much appreciated!
 
Solved!!! For reference:

Code:
DEFINE VARIABLE objAddress          AS CLASS "IAddress".
DEFINE VARIABLE objConnection       AS CLASS "IConnection".
DEFINE VARIABLE objConnectionArray  AS CLASS "IConnection[]".

objAddress = NEW Address().
objConnectionArray = objAddress:connections.    /* This is an array containing "connections" - which are objects)
objConnection = [B]CAST[/B](objConnectionArray.GetValue(1), iConnection).
 
Back
Top