65.9K
CodeProject is changing. Read more.
Home

Useful Refactoring Trick with instance variables

starIconstarIconstarIconstarIcon
emptyStarIcon
starIcon

4.33/5 (3 votes)

Sep 14, 2010

CPOL
viewsIcon

5758

Visual Studio's refactoring tools are great. On a particular note, the CTRL + R, E would signal VS to generate the properties of the selected member. What it does is it turns the member private and generates the get and set properties. However, the new property will be generated right below the field. You have no control over this. If you wait (as I did) by writing all the instance variables first and refactoring them to become private later, you would end up with a property below every field (It would seem messy). Hence, I suggest to quickly refactor every time you create an instance variable destined to be a property.