Hi I'm doing changes to my project and look for a smooth way of changing name of variables, classes and methods and such. I've read somewhere that you can "change all xxx to xxx" in project but I'm having a hard time finding info of how you do it.
-
What are you talking about? A class? A method? A variable?Kahn Kah– Kahn Kah2017-05-24 09:18:25 +00:00Commented May 24, 2017 at 9:18
-
For example: I have changed a name of some of my methods in code, call it a clean-up, and to rename all references I think there is a way that should do it in one sweep but I can't find info about it and I'm quite new at VS.Tarbh– Tarbh2017-05-24 09:21:35 +00:00Commented May 24, 2017 at 9:21
-
Press F2, it is awesome.Jesse de Wit– Jesse de Wit2017-05-24 14:37:02 +00:00Commented May 24, 2017 at 14:37
4 Answers
If it's a class file with .cs extension then select the file from Solution Explorer > Right Click > Rename
After you rename, it will ask you whether you want to change it even in references like this

But if you want to rename a method then you can also use the following refactor feature:
Double Click and Select the Method > Right Click > Refactor > Rename
Refactor feature in Visual Studio works for all: classes, methods and variables.
Comments
Right-click on your variable and click Rename.
Then you can change its name, and confirm in the box that has appeared in visual studio.
