Export (0) Print
Expand All
Expand Minimize

Compiler Error CS0170

Use of possibly unassigned field 'field'

A field in a structure was used without first being initialized.

The following sample generates CS0170:

// CS0170.cs
public struct error
{
   public int i;
}

public class CmyClass
{
   public static void Main()
   {
      error e;
      // uncomment the next line to resolve this error
      // e.i = 0;
      System.Console.WriteLine( e.i );   // CS0170
   }
}
Show:
© 2014 Microsoft