超簡單的問題...如何正確初始化結構上的私有後臺字段?我得到一個編譯器錯誤:如何使用編譯器生成的後臺字段初始化結構
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; }
}
你何時何地得到錯誤? –