Sometimes your C# file name and class name are different for whatever reason and you want to fix it. The usual way of “fixing” this issue is either by renaming the file name in solution explorer or changing the class name using Ctrl R + Ctrl R shortcut. None of these are two that bad of options but Visual Studio 2017 has introduced a better way of handle this scenario. Let’s consider following scenario where class name is Foos whereas the file name is Foo.cs.
Let’s say the class Foos is used as follows.
Within Visual Studio 2017, if you click the cursor on the class name and then press the Quick re-factoring shortcut (Ctrl + .), you will get the two options of either renaming the file or renaming the class as shown in figure below.
Let’s say I choose to rename the type of Foos to Foo from the menu item. With one click, it will not only rename the class itself but also wherever this class is referred as shown below.
Until next, happy debugging!!