Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Compiler Error CS0571
Collapse the table of content
Expand the table of content

Compiler Error CS0571

'function' : cannot explicitly call operator or accessor

Certain operators have internal names. For example, op_Increment is the internal name of the ++ operator. You should not use or explicitly call such method names.

The following sample generates CS0571:

// CS0571.cs
public class MyClass
{
   public static MyClass operator ++ (MyClass c)
   {
      return null;
   }

   public static int prop
   {
      get
      {
         return 1;
      }
      set
      {
      }
   }

   public static void Main()
   {
      op_Increment(null);   // CS0571
      // use the increment operator as follows
      // MyClass x = new MyClass();
      // x++;

      set_prop(1);      // CS0571
      // try the following line instead
      // prop = 1;
   }
}
Show:
© 2015 Microsoft