Have you ever written some code and named something one thing only to realize that it should be named something else?
If you haven’t you haven’t been programming for very long. Maybe you started a new job and you spent two weeks writing code using your previous employer’s naming conventions only to find out that this employer expects things to be named slightly differently.
So now you not only have the item named incorrectly, but you’ve referenced it from other files, so it isn’t a simple matter of just giving it a new name. No, the code that is referencing it has to be changed as well. So what are you going to do?
In the “old days” we’d change the name, recompile and fix all the references. But now there is a much easier way to fix this problem. All you need to do is to right-click on the property, method, or variable and select “Refactor” > “Rename…” from the context menu.
This will bring up a dialog box where you can give the item a new name and optionally select if you’d like to preview the changes, make changes in your comments (that are also referencing this variable name) and search for it in strings.
Press “OK” to continue and all of the names of the item as well as all of the references to that item will automatically be changed for you.
Other post in Did you know
- Did you know - Zip is built into .NET? - August 21st, 2008
- Automatic Implementation of Interfaces - October 1st, 2008
- Easily Find Classes, Methods, and Variables - November 17th, 2008
- Advantages of Using Class Diagram - November 20th, 2008
- Panel DefaultButton does not work - December 25th, 2012
- Finding a CSS Class Definition - May 29th, 2013
- Renaming Properties, Methods and Variables - November 13th, 2013
- Effective Hacks to Enhance IT Careers of College Students - September 3rd, 2015