Export (0) Print
Expand All

4.5.2 Function Return Syntax

Visual Studio .NET 2003

Unlike Standard C++, a __gc array can be returned from a function. The syntax follows the C++ style for putting the array brackets after the declarator.

Example

// __gc_arrays3.cpp
// compile with: /clr
#using <mscorlib.dll>
using namespace System;

// f returns a __gc array of Int32
Int32 f() [] { return new Int32[100]; };

int main() {
   f()[5] = 20;
}
Show:
© 2014 Microsoft