컴파일러 오류 CS1526
업데이트: 2007년 11월
오류 메시지
new 식은 형식 뒤에 (), [], 또는 {}가 필요합니다.
A new expression requires (), [], or {} after type
개체에 메모리를 동적으로 할당하는 데 사용하는 new 연산자를 잘못 지정했습니다.
예제
다음 샘플에서는 new를 사용하여 배열과 개체에 공간을 할당하는 방법을 보여 줍니다.
// 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
}
}