Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.
We recommend using Visual Studio 2017

Compiler Error C2727

 

'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: