Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

Compiler Error C2728

'type' : a native array cannot contain this managed type

Array creation syntax was used to create an array of managed objects. You cannot create an array of managed objects using native array syntax.

For more information, see array.

The following sample generates C2728:

// C2728.cpp
// compile with: /clr

int main() {
   int^ arr[5];   // C2728
   
   // try the following line instead
   array<int>^arr2;
}

A __nogc array cannot be of a __gc type.

The following sample generates C2728:

// C2728_b.cpp
// compile with: /clr:oldSyntax
#using <mscorlib.dll>

int main() {
   int __gc* arr __nogc[5];   // C2728

   // try the following line instead
   int arr2 __gc[];
}

Community Additions

ADD
Show:
© 2015 Microsoft