С учетом следующего кода:
public struct Foo
{
public Foo(int bar, int baz) : this()
{
Bar = bar; // Err 1, 2
Baz = baz; // Err 3
}
public int Bar { get; private set; }
public int Baz { get; private set; }
}
Что делает : this()
на самом деле? Нет конструктора по умолчанию, так что он звонит? Без этого добавления все происходит с ошибками.
Error 1 The 'this' object cannot be used before all of its fields are assigned to Error 2 Backing field for automatically implemented property 'Foo.Bar' must be fully assigned before control is returned to the caller. Consider calling the default constructor from a constructor initializer. Error 3 Backing field for automatically implemented property 'Foo.Baz' must be fully assigned before control is returned to the caller. Consider calling the default constructor from a constructor initializer.