Skip to main content

Redundant constructor

In This Article

CodeRush Classic shows the Redundant constructor code issue if a default constructor is the only constructor declared in a class or struct, provided that its body is empty.

#Fix

Remove the redundant constructor.

#Purpose

Highlights the redundant constructors, which can be removed to improve code readability.

#Example

public class MyClass
{
    public MyClass()
    {

    }
    public string Name { get; set; }
}

Fix:

public class MyClass
{
    public string Name { get; set; }
}