매우 간단한 질문 ... 구조에서 개인용 백킹 필드를 올바르게 초기화하는 방법은 무엇입니까? 컴파일러 오류가 발생합니다.컴파일러에서 생성 된 백킹 필드로 구조를 초기화하는 방법
Backing field for automatically implemented property 'Rectangle.Y' must be fully assigned before control is returned to the caller. Consider calling the default constructor from a constructor initializer.
소스 코드를 참조하십시오.
public struct Rectangle
{
public Rectangle(int x, int y, int width, int height)
{
X = x;
Y = y;
Width = width;
Height = height;
}
public int Width { get; private set; }
public int Height { get; private set; }
public int X { get; private set; }
public int Y { get; private set; }
}
어디에서 오류가 발생합니까? –