The Convert Method to Property refactoring converts non-void methods without parameters to read properties, and void methods with exactly one parameter to write properties.
- Place the caret at the name of a method in the editor, in the File Structure window, in Class View or in Object Browser.
- Do one of the following:
- On the main menu, choose Refactor | Convert | Method to Property.
- Press Ctrl+Shift+R and click Convert Method to Property.
- The Convert Method to Property dialog opens. Type a property name into the Property name box or leave the default one:
- Click Next to change the method to a read or a write property. At the same time, all method calls will be substituted with the corresponding property accesses.
Consider the example below:
After applying the refactoring, the
GetFilteredChildren method is replaced with the