The Convert Property to Method(s) refactoring converts type properties to getter and/or setter methods. Namely, each read property is converted to a getter method, each write property is converted to a setter method, and each read-write property is converted to two separate methods: a getter and a setter.
- Place the caret at the name of the property in Class View, Object Browser, or in the code editor.
- On the main menu or context menu, choose Refactor | Convert Property to Method(s):
- In the dialog box that opens, specify the names of the getter and/or setter methods.
NoteFor a read-write property you may generate a pair of getter-setter methods, or either getter or setter, by selecting the appropriate check boxes. You also have the possibility to change the default method names suggested by ReSharper.
- Click Continue. The property changes to getter/setter method(s). At the same time, all usages of the property (both read and write) will be substituted with the corresponding method calls.
Consider the following example:
After converting property
a pair of getter/setter methods, the code looks as follows: