Show/Hide Toolbars

XSharp

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

 

All fields in a struct have to be assigned by a constructor before the constructor can call a method in the struct.

 

If you see this error when trying to initialize a property in a struct constructor, the solution is to change the constructor parameter to specify the backing field instead of the property itself. Auto-implemented properties should be avoided in structs because they have no backing field and therefore cannot be initialized in any way from the constructor.

 

For more information, see Using Structs.

Example

 

The following sample generates XS0188:

 

 

// XS0188.prg  
// compile with: /t:library