Compiler Error CS1526
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
}
}
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for