I have a class A
in file B.cs
. Now I want to rename this class to match the file name (B
).
Is there a refactoring or context action in VS or ReSharper which automatically can do this renaming for me without typing in the new name matching file name?
Before renaming:
File B.cs:
class A {}
After automatically renaming:
File B.cs:
class B{}
The opposite (automatically rename file to match class name) is not an option because all these file renamings are implemented as DELETE+ADD. But then I would lose change history of that file in Perforce because all VS-Plug-ins for VS-Perforce-connection do not support move/add+move/delete actions for renaming.
In Visual Studio, you can right click on the class name inside the .cs file and rename it by choosing "Refactor --> Rename". It will give you the option to refactor it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With