Refactoring – a new feature in the Visual C# 2.0 IDE
Renaming variables:
Assume you have a solution containing about 25 classes (we’ll also assume that each class is in a separate source file – that means 25 .cs files).
Suppose one class has a variable xyz, which you now want to rename to something more meaningful. In Visual Studio .Net 2003, what options did you have? You could do a find and replace for “xyz” (to rename it to something else, says “username”), but this would also rename variables like “abc
xyz” to “abc
username”! You could of course choose the “Find whole word” option, but another problem – this would also rename variables named “xyz” in other classes which you might not want to touch.
The Visual C# 2005 IDE has a new feature which you can use. Lets look at the screen shot below:

In the above image, I want to rename the "username" variable. Within the Visual C# 2005 IDE, I right click on the variable name. Within the context menu that pops up, I choose "Refactor" and then "Rename". A dialog box pops up as shown in the image below:

I type in the new variable name. Suppose I type in "newusername". The IDE determines what all changes have to be made within the solution. Look the image below. You'll see that both instances of "username" have been changed to "myusername".

What's so great you might ask - after all, this could have been done by a simple find and replace. You're right - but that would have worked only for this simple case. Assume "username" was a public variable, and was being used by other classes too. On renaming the variable using the refactoring method above, all the places where the variable was being used (within the current solution), would get renamed to the new name.