Antonio,
One of the constructors of the ArrayList class accepts an ICollection as
parameter. Stack is a class that implements the ICollection interface. So
what I am suggesting here is to use a temporary class to push your objects,
and then create the ArrayList from the stack.
..locals init ([0] class [mscorlib]System.Collections.Stack stack,
[1] class [mscorlib]System.Collections.ArrayList arraylist)
newobj instance void [mscorlib]System.Collections.Stack::.ctor()
stloc.0
ldloc.0
ldc.i4.s 123
box [mscorlib]System.Int32
callvirt instance void
[mscorlib]System.Collections.Stack::Push(object)
ldloc.0
ldc.i4 456
box [mscorlib]System.Int32
callvirt instance void
[mscorlib]System.Collections.Stack::Push(object)
ldloc.0
newobj instance void
[mscorlib]System.Collections.ArrayList::.ctor(class [mscorlib]
System.Collections.ICollection)
stloc.1
Maybe having a temporary variable is not the most elegant solution, but it
is something that VB.NET and C# compilers often do.
Gabriele
[quoted text, click to view] "Antonio Linares" <alinaresREMOVE_THIS@fivetechsoft.com> wrote in message
news:u167D6uPDHA.3192@TK2MSFTNGP10.phx.gbl...
> I am curretly porting an open source language
www.harbour-project.org to
> .NET.
>
> I have the following IL coding question, hopefully someone may provide me
> some guidance:
>
> I have some objects ("object" type) placed at the stack. Then I need to
> create an ArrayList and pop those objects from the stack and add them to
the
> array. i.e.:
>
> ldc.i4.s 123
> box [mscorlib]System.Int32
> ldc.i4.s 456
> box [mscorlib]System.Int32
> call object ObjArrayGen( int32 ) // I do know how many objects
are
> placed at the stack
>
> The question is how could I pop those objects from the stack and add them
to
> a new created ArrayList from inside ObjArrayGen() ? I can't create a
> object[] in advance (I already considered such way).
>
> thanks!
>
> Please remove REMOVE_THIS from my address to answer me directly.
>
> Antonio
>
>