This documentation is archived and is not being maintained.

Compiler Error C2727

cannot create non __gc array 'array' because type 'typename' contains members with type __gc *

A __nogc array cannot be of a type that contains __gc types.

The following sample generates C2727

// C2727.cp
// compile with: /clr
#using <mscorlib.dll>
using namespace System;
__value struct V
   // char * s;

int main()
   V v __nogc[5];   // C2727
   v[0].s = S"test";
   // v[0].s = "test";