Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rename class with file name in one step in Visual Studio

Tags:

I am a long year Java programmer, but currently I code in C#. I am accustomed, that when I change filename, also the class name changes and vice versa. This doesn't work in my Visual Studio. I must rename the class name and file name separately, and it's sometimes annoying for me, because I always forget on it, so it results to that I have different class and file names. Is there option in Visual Studio to put the renaming in one step?

like image 898
xMichal Avatar asked Nov 27 '13 13:11

xMichal


People also ask

How do I rename a class in Visual Studio?

Select Edit > Refactor > Rename. Right-click the code and select Rename.

How do I rename all occurrences in Visual Studio?

First put your cursor on the member and click F2 . Then type the new name and hit the Enter key. This will rename all of the occurrences in every file in your project.


1 Answers

Renaming a file works fine - it'll offer to change the code to match:

enter image description here

If you rename the class, then - indeed, this doesn't happen by default. There is no actual need for the two to match, note. But ultimately, rename is only an f2 away.

like image 99
Marc Gravell Avatar answered Sep 18 '22 01:09

Marc Gravell