Export (0) Print
Expand All
Expand Minimize

Compiler Error CS0201 

Error Message

Only assignment, call, increment, decrement, and new object expressions can be used as a statement

The compiler generates an error when it encounters a meaningless statement.

Example

The following sample generates CS0201.

// CS0201.cs
public class MainClass
{
   public static void Main()
   {
      2 * 3;   // CS0201
   }
}

The following sample generates CS0201.

// CS0201_b.cs
// compile with: /target:library
public class MyList<T> 
{
   public void Add(T x)
   {
      int i = 0;
      if ( (object)x == null)
      {
         checked(i++);   // CS0201

         // OK
         checked {
            i++; 
         }
      }
   }
}

Community Additions

ADD
Show:
© 2014 Microsoft