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 CS0270 

Error Message

Array size cannot be specified in a variable declaration (try initializing with a 'new' expression)

This error occurs when a size is specified as part of an array declaration. To resolve, use the new Operator expression.

The following example generates CS0270:

// CS0270.cs
// compile with: /t:module

public class Test
{
   int[10] a;   // CS0270
   // To resolve, use the following line instaead:
   // int[] a = new int[10];
}

Community Additions

ADD
Show:
© 2015 Microsoft