Sometimes you start with creating a class property but later you realised that there is much more work in that property and it’s better to have it as a method. Visual Studio 2017 converting a property to a method quite trivial. Let’s say we have a class Bar with a property BarId as shown below.
Let’s say you want to convert it to a method. For that, you just click on the property name BarId and then bring up Refactoring helper by press “Ctrl + .”. This will pop-up the option for Replacing BarId with methods as shown below. The preview window shows that change that will happen due to this refactoring as well.
Once you preform the refactoring, the code will be changed to have a private field barId and a pair of setter/getter method for this field as shown below.
Until next, happy debugging.