Search code examples
c#visual-studio-2010refactoringrename

rename class with file name in one step in Visual Studio


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?


Solution

  • 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.