Compiler Error CS0188
TOC
Collapse the table of content
Expand the table of content
The document is archived and information here might be outdated

Compiler Error CS0188

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.

The following sample generates CS0188:

// CS0188.cs
struct s
{
   public int a;

   void f()
   {
   }

   s (int i)
   {
      // a = i;
      f();  // CS0188
   }
}

class MyClass
{
   public static void Main()
   {
   }
}
Show:
© 2016 Microsoft