Skip to main content

Pull Member Up

  • 2 minutes to read

Purpose

Moves a member with its dependencies to a base type.

Availability

Available when the caret is in a type member. The base type code should exist in the current solution.

Note

This refactoring is not available for interfaces.

Usage

  1. Place the caret in a member declaration.

    class BaseClass {
    
    }
    class MyBaseClass : BaseClass {
    
    }
    class MyClass : MyBaseClass {
    
        public void IncrementValue(int interval) {
            Value += interval;
        }
    
        public int Value { get; set; }
    }
    
  2. Press the Ctrl + . or Ctrl + ~ shortcut to invoke the Code Actions menu.
  3. Select Pull Member Up from the menu. If there are several base types in the current solution, you can select the target type from the submenu.

    pull-member-up-menu

After execution, the Refactoring moves a member with its dependencies to a base type.

class BaseClass {

    public void IncrementValue(int interval) {
        Value += interval;
    }

    public int Value { get; set; }

}
class MyBaseClass : BaseClass {

}
class MyClass : MyBaseClass {
}