C#

C#

Made by DeepSource

Explicit default constructors are redundant CS-R1028

Anti-pattern
Major

Constructors that do not take any parameters and with empty bodies are redundant and same as default constructors. Such constructors are usually defined when auxiliary constructors, i.e. additional overloaded constructors are defined. It is therefore recommended that you drop the explicit definition since you do not have any auxiliary constructors defined.

Bad practice

class C
{
    public C()
    {
    }
}

Recommended

class C
{
    public C()
    {
    }
}

// Valid scenario
class C
{
    private int x;

    public C()
    {
    }

    // `auxiliary` constructor
    public C(int x)
    {
        this.x = x;
    }
}

Reference