This documentation is archived and is not being maintained.

Compiler Error C2727

Error Message

'type' : a native array cannot contain a value type with private data members or managed pointer members

Managed Extensions for C++

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

C2727 is only reachable using /clr:oldSyntax

The following sample generates C2727

// C2727b.cpp
// compile with: /clr:oldSyntax
#using <mscorlib.dll>
using namespace System;
__value struct V {
   String * s;
};

__value struct V2 {
   char s;
};

int main() {
   V v __nogc[5];   // C2727
   V2 v2 __nogc[5];   // OK
}
Show: