Remove Unused Member

Purpose

Used to remove a private class member (field, property, method, event, etc.), which is never used.

Availability

Available when the cursor is on the member name, providing this member is never assigned or referenced.

Usage

  1. Place the caret on an unused member name.

    Note

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

    public class Person {
        private int CustomerID;
        public string FirstName { get; set; }
        public string LastName { get; set; }
    }
    
  2. Use the Ctrl + . or Ctrl + ~ shortcut to invoke the Code Actions Menu.
  3. Select Remove Unused Member from the menu.

After execution, the Refactoring removes the member.

public class Person {
    public string FirstName { get; set; }
    public string LastName { get; set; }
}

See Also