Visual Studio 2017 has introduced new quick ways to refactor your code. One such refactoring is about moving a class in a new file. There are use cases when a developer may have created many classes in a single file. As shown in figure below, Let’s say I have two classes Foo and Bar in the same file called Foo.cs.
With Visual Studio 2017 refactoring improvements, its now much easier to move classes into a separate file of its own. In order to do that you just move cursor on the class name Bar within the Editor and right click. This will show the familiar menu options including “Quick Actions and Refactorings”.
You can either choose this menu option or the shortcut Ctrl + . which will bring up the new refactoring option of “Move type into Bar.cs”.
Once you choose that option, the class Bar will be moved to a new file called Bar.cs as shown in image below.
Until next, happy debugging!!!