The requested page is not available for the requested platform. You are viewing the content for Default platform.

Overloaded unary operator takes one parameter

CodeRush Classic shows the Overloaded unary operator takes one parameter code issue if an overloaded unary operator does not have parameters.

Fix

Add a parameter to the overloaded unary operator declaration.

Purpose

Highlights the operator declarations, which would cause the Overloaded unary operator takes one parameter compilation error.

Example

public class MyData
{
    public MyData(string name, List<string> data)
    {
        Name = name;
        Data = data;
    }
    public string Name { get; set; }
    public List<string> Data { get; set; }
    public static MyData operator ++()
    {

    }
}

Fix:

public class MyData
{
    public MyData(string name, List<string> data)
    {
        Name = name;
        Data = data;
    }
    public string Name { get; set; }
    public List<string> Data { get; set; }
    public static MyData operator ++(MyData d1)
    {
        d1.Data.Add(string.Empty);
        return d1;
    }
}