Encapsulate Fields Dialog Box

See Also

Use this dialog box to specify options for the Encapsulate Fields refactoring command. You can use the Encapsulate Fields command to create accessor methods for fields in a class. With the Encapsulate Fields command, you can also have direct references to those fields replaced with calls to the newly created accessor methods. Accessor methods are also referred to as getters and setters or read/write methods.

You can open the Encapsulate Fields dialog box from the Source Editor, Projects window, or Files window. In one of these windows, right-click a field (or a reference to the field elsewhere in your code) and choose Refactor > Encapsulate Fields.

The dialog box has the following fields:

If you want to preview the changes, you need to follow these steps to complete the refactoring:

  1. Click Preview.

    The Refactoring window opens and displays a tree view of the code to be affected by the refactoring.

  2. Check the items displayed in the Refactoring window to make sure that you want them all changed. Clear the checkbox next to any parts of the code that you do not want changed.
  3. Click Do Refactoring.
See Also
About Refactoring
Refactoring: Quick Reference
Undoing Refactoring Changes

Legal Notices