ReSharper 8.0 Web Help

The Convert Property to Method(s) refactoring converts type properties to getter and/or setter methods. A read property is converted to a getter method, a write property is converted to a setter method, and a 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).
    • Choose Refactor | Convert | Property to Method(s) on the context menu.
    • Press Ctrl+Shift+RCtrl+Shift+R, then click Convert Property to Method(s).
  3. The Convert Property to Method(s) dialog box opens. Type method names in the appropriate text boxes or leave the default ones:



    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. If no conflicts are found, ReSharper performs the refactoring immediately and 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. Otherwise, resolve conflicts.

Consider the example below:


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


This feature is supported in the following languages/technologies:

C# VB.NET HTML ASPX Razor JavaScript TypeScript CSS XML XAML RESX Build Scripts
feature_available feature_available


The instructions and examples given here address the use of the feature in C#. For details specific to other languages, see the corresponding topics in the ReSharper by Language section.