I often code in such way that I put several classes in one cs file to get my code going and then at some point, I want to move every class to a seperate .cs file within my C# project but I have to do this manually by creating a file for every class and cut and paste the class to the new file and then resolve the required namespace one by one for each file. No Fun!
Is there a way to just click right on the class and make visual studio to automatically move the class to a new file under the project tree? I mean, would you please provide such Macro/Snippet(or whatever it is called :) ) and instructions on how to add it to Visual Studio 2010?
Open Visual Studio, and choose Create a new project in the Start window. In the Create a new project window, select All languages, and then choose C# from the dropdown list. Choose Windows from the All platforms list, and choose Console from the All project types list.
To add a class in a Visual Studio C++ project, in Solution Explorer, right-click the project, choose Add, and then choose Class. This command opens the Add Class dialog box. When you add a class, you must specify a name that is different from classes that already exist in MFC or ATL.
Files with . cs extension are source code files for C# programming language. Introduced by Microsoft for use with the . NET Framework, the file format provides the low-level programming language for writing code that is compiled to generate the final output file in the form of EXE or a DLL.
Open Program. cs by clicking on it. The first time you open a C# file in Visual Studio Code, OmniSharp loads in the editor. Select Yes when Visual Studio Code prompts you to add the missing assets to build and debug your app.
If anyone is looking for a lightweight solution to this problem I found a free Move Type To File extension specifically for this purpose.
http://visualstudiogallery.msdn.microsoft.com/5746c6ea-1f92-43f0-8bab-ec6f8573cd6a
I think Resharper has the functionality you want (plus so much more).
Visual Studio 2017 now has Code Refactoring that includes Moving a class into its own file.
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