'this' 对象在其所有字段都分配给之前不能使用

The 'this' object cannot be used before all of its fields are assigned to

Constructor有问题:

The 'this' object cannot be used before all of its fields are assigned to.

但在 Month 的相同情况下,在 Constructor 中它起作用了。为什么?

struct Date
{
    private byte day;

    public byte Day
    {
        get { return day; }
        set {
            if (value > 0 && value < 32)
                day = value;
            else
                day = 0;
        }
    }

    private byte month;

    public byte Month
    {
        get { return month; }
        set
        {
            if (value > 0 && value < 13)
                month = value;
            else
                month = 0;
        }
    }

    public Date(byte day, byte month)
    {
        Day = day;
        Month = month;
    }
}

它不会,编译器只是在第一个错误后停止。如果您注释掉 Day = day,您将在 Month = month.

上看到相同的错误

(使用 dotnetfiddle/.NET 4.7.2 测试,我想其他编译器可能不同。)

感谢您的帮助。 我找到了解决方案。 我试图将 struct 更改为 class for Date。成功了。

class Date

{

}