MC++ FAQ
Thursday 06 | 27 | 2002
int[] by reference
How can I define a method that takes an array of ints by reference?

R/ Try something like this:

void MethodWithRef(System::Int32 (&intArray) __gc[]) {
    const size_t arraySize = 2;
     intArray = new int __gc[arraySize];
     // fill array
}
Posted by tomasr at June 27, 2002 01:10 AM
Comments

In general I hate typedefs but I think they can really help make this more readable.

These two methods compile with the same signature, as seen in ILDASM.

void Proc1(int (&a) __gc[]){
Console::WriteLine(S"Blah");
}

typedef int IntGcArray_T __gc[];

void Proc2(IntGcArray_T& a){
Console::WriteLine(S"Bleh");
}

Posted by: Adam on July 11, 2003 10:52 PM
Post a comment
Name:


Email Address:


URL:


Comments:


Remember info?

Copyright(C) 2002, Tomas Restrepo, All rights reserved. Powered by Movable Type 2.63