Convert Method to Property refactoring

Last modified: 23 September 2024

This refactoring helps you convert methods with return values and without parameters to properties with the corresponding get accessor, and methods with void return type and exactly one parameter to properties with the corresponding set accessor.

Consider the following example:

If there is an existing property with a single accessor and the converted method has compatible parameter type or return type, the refactoring can add the second accessor to the existing property:

ReSharper refactorings: Convert method to property dialog

This feature is supported in the following languages and technologies:

The instructions and examples given here address the use of the feature in C#. For more information about other languages, refer to corresponding topics in the Languages and frameworks section.