HomeCSharpC# Error CS1535 – Overloaded unary operator ‘{0}’ takes one parameter

C# Error CS1535 – Overloaded unary operator ‘{0}’ takes one parameter

C# Error

CS1535 – Overloaded unary operator ‘{0}’ takes one parameter

Reason for the Error & Solution

Overloaded unary operator ‘operator’ takes one parameter

The definition of a unary must take one parameter.

Example

The following sample generates CS1535:

// CS1535.cs  
class MyClass  
{  
    // uncomment the method parameter to resolve CS1535  
    public static MyClass operator ++ (/*MyClass MC1*/)   // CS1535  
    {  
        return new MyClass();  
    }  
  
    public static int Main()  
    {  
        return 1;  
    }  
}  

Leave a Reply

You May Also Like

This C# program calculates and displays an upper triangular matrix based on user input. Problem Statement: The program takes the...
This C# program serves as a demonstration of bitwise operators, which are fundamental operators used for manipulating individual bits in...
This C# program is designed to interchange or swap the columns of a matrix. A matrix is a two-dimensional array...