Export (0) Print
Expand All
Expand Minimize

Compiler Error C2814

'member' : a native type cannot be nested within a managed type 'type'

A native type cannot be nested in a CLR type. The following sample generates C2814.

// C2814.cpp
// compile with: /clr /c
ref class A {
   class B {};   // C2814
   ref class C {};   // OK
};

You must explicitly specify the "managed-ness" of an embedded type using one of the following keywords: __gc, __nogc, or __value.

The following sample generates C2814.

// C2814_b.cpp
// compile with: /clr:oldSyntax /c
__gc class A {
   class B {};   // C2814
   __gc class C {};   // OK
};
Show:
© 2014 Microsoft