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 CS1526 

Error Message

A new expression requires () or [] after type

The new operator, used to dynamically allocate memory for an object, was not specified correctly.

Example

The following sample shows how to use new to allocate space for an array and an object.

// CS1526.cs
public class y
{
   public static int i = 0;
   public int myi = 0;
}

public class z
{
   public static void Main()
   {
      y py = new y;   // CS1526
      y[] aoys = new y[10];   // Array of Ys

      for (int i = 0; i < aoys.Length; i++)
         aoys[i] = new y();   // an object of type y
   }
}

Community Additions

ADD
Show:
© 2015 Microsoft