Skip to main content

Remove Redundant Destructor (C#)

Removes the destructor under the cursor, if it does not contain executable code.

#Availability

Available from the context menu or via shortcuts:

  • when the cursor is on a destructor declaration, provided that the destructor does not contain executable code lines.

#Examples

class TestClass
{
    private string _name;
    public TestClass(string param)
    {
        _name = param;
    }~ TestClass()
    {

    }
}

Result:

class TestClass
{
    private string _name;
    public TestClass(string param)
    {
        _name = param;
    }
}

#Screenshot

rsRemoveRedundantDestructor