Back to Devexpress

Remove Redundant Destructor

coderushforroslyn-115565-refactoring-assistance-remove-redundant-destructor.md

latest1.2 KB
Original Source

Remove Redundant Destructor

  • Aug 03, 2020

Purpose

Removes the destructor if it does not contain executable code. In most cases, you don’t have to implement a destructor, as the garbage collector disposes of objects automatically.

Availability

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

Usage

  1. Place the caret on an empty destructor declaration.

  2. Press the Ctrl + . or Ctrl + ~ shortcut to invoke the Code Actions menu.

  3. Select Remove Redundant Destructor from the menu.

After execution, the Refactoring removes the destructor.

csharp
public class Person {
    private int id;
    public string Name { get; set; }
}

See Also

Remove Redundant Constructor

Remove Unused Member

Remove Redundant Assignment

Add/Remove Block Delimiters