Tuesday, November 13, 2007

__gc Array Aggregate Initialization

__gc Array Aggregate Initialization doesn't work inside a namespace (except that the method is a member of a gc class). We have to initialize each element one by one.

namespace Sample
{
void ParseString(String* str)
{
...
Char splitter[] = { ',' }; // This will cause link error
// Use the following instead
// Char splitter[] = new Char[1];
// splitter[0] = ',';
...
}
}

No comments: