0

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.

3
  • What are you talking about? A class? A method? A variable? Commented 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. Commented May 24, 2017 at 9:21
  • Press F2, it is awesome. Commented May 24, 2017 at 14:37

4 Answers 4

4

Right click Rename, renames all references and mentions of your function variable etc.

Sign up to request clarification or add additional context in comments.

Comments

2
+50

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 enter image description here

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

Example in Screenshot:enter image description here

Refactor feature in Visual Studio works for all: classes, methods and variables.

Comments

2

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.

See this MSDN Article.

Comments

0

Look at "Resharper" or other Addins that are even smarter. They can find also references in comments or source code that is not directly related.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.