Skip to main content

Redundant destructor

In This Article

CodeRush Classic shows the Redundant destructor code issue if a destructor is empty.

#Fix

Remove the empty destructor.

#Purpose

Highlights the destructors that can be removed to improve code readability.

#Example

public class MyClass
{
    public MyClass(string name)
    {
        Name = name;
    }
    public string Name { get; private set; }
    public object Value { get; set; }~MyClass()
    {

    }
}

Fix:

public class MyClass
{
    public MyClass(string name)
    {
        Name = name;
    }
    public string Name { get; private set; }
    public object Value { get; set; }
}