All structure variables must be assigned before you can use any methods or properties. Two possible errors are possible here:
1) You can explicitly call the constructor without parameters:
public A(int x) : this() { B = x; }
2) You can use the field instead of the property:
public A(int x) { b = x; }
Of course, the second option only works in your current form - you need to use the first option if you want to change the structure in order to use the automatic property.
However, importantly, you now have a mutable structure. This is almost always a very bad idea . I urge you to use something like this:
struct A { private readonly int b; public A(int x) { b = x; } public int B { get { return b; } } }
EDIT: More on why the source code doesn't work ...
From section 11.3.8 of the C # specification:
If the constructor of the struct instance does not specify a constructor initializer, the this variable matches the out parameter of the structure type
Now, initially this will not be definitely assigned, which means that you cannot execute any member function (including means for defining properties) until all the first structures of the structure are defined. The compiler does not know and is not trying to take into account the fact that the property setting tool is not trying to read from another field. All this helps to avoid reading from fields that were not specifically assigned.
Jon skeet
source share