This documentation is archived and is not being maintained.

4.5.7 Aggregate Initialization

Visual Studio .NET 2003

A __gc array can be initialized with a curly-brace list, following the same rules as for __nogc arrays.

Aggregate initialization is useful for constructing function arguments of array type. Examples are Console::WriteLine, System::Array::SetValue, and System::Array::GetValue.


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

int main() {
   String *args[] = {S"hello", S"world", S"how", S"are", S"you"};
   Console::WriteLine(S"{0} {1} {2} {3} {4}", args);


hello world how are you