All docs
V19.2
19.2
19.1
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.

Remove Unused Type

Purpose

Removes types that are never executed or referenced.

You can use this refactoring to ensure the type you want to delete is not referenced in your code.

Note

Currently, this refactoring cannot be applied to public types.

Availability

Available when the cursor is in a type declaration. This type is never used in code.

How to Use

  1. Place the caret in an unused type declaration.
Note

The blinking cursor shows the caret's position where Refactoring is available.

public class UsedClass
{
    private class  UnusedClass
    {

    }
}
  1. Use the Ctrl + . or Ctrl + ~ shortcut to invoke the Code Actions Menu.

OrganizeMembersPage

  1. Select Remove Unused Type from the menu.

After execution, the Refactoring removes the unused type.

public class UsedClass
{

}