ReSharper Web Help

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.

To change a property to setter/getter methods
  1. Place the caret at the name of a property in the editor, in the File Structure window, in Class View or Object Browser.
  2. Do one of the following:
    • On the main menu, choose ReSharper| Refactor | Convert | Property to Method(s).
    • Press Ctrl+Shift+R, then click Convert Property to Method(s).
  3. The Convert Property to Method(s) dialog opens. Type method names in the appropriate boxes or leave the default ones:

     Note

    For a read-write property you may generate a pair of methods, or a single method for either getter or setter, by leaving the appropriate check box selected.
  4. Click Next. The property is converted into appropriate 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 example below:

After converting the BackgroundColor property into a pair of methods, the code looks as follows:

See Also

Procedures