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;
}
}
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for