Pull Member Up

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.

    Note

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

    class BaseClass {
    
    }
    class MyBaseClass : BaseClass {
    
    }
    class MyClass : MyBaseClass {
    
       public void IncrementValue(int interval) {
            Value += interval;
        }
    
        public int Value { get; set; }
    }
    
  2. Use 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.

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 {
}