超簡単な質問...構造体のプライベートバッキングフィールドを適切に初期化するにはどうすればよいですか? コンパイラ エラーが発生します。
自動的に実装されたプロパティ 'Rectangle.Y' のバッキング フィールドは、コントロールが呼び出し元に返される前に完全に割り当てられている必要があります。コンストラクター初期化子から既定のコンストラクターを呼び出すことを検討してください。
ソースコードはこちら。
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; }
}