Is it possible to change the template in Visual Studio 2010 so that the class definition is changed from:
class Class1 { }
to:
public class Class1 { }
When creating a new class via Add->Class in the context menu.
I would also ideally like to be able to create a class in one context menu click. I copy+paste existing class files to avoid the file dialog.
Reset settingsSelect Tools > Import and Export Settings from the menu bar to open the Import and Export Settings Wizard. In the Import and Export Settings Wizard, select Reset all settings, and then select Next. On the Save Current Settings page, select either Yes or No, and then select Next.
To set this compiler option in the Visual Studio development environment. Open the project's Property Pages dialog box. For more information, see Set C++ compiler and build properties in Visual Studio. Select the Configuration Properties > C/C++ > Language property page.
The standard wayOn the tab Installed, click button Modify next to the version of Visual Studio you need the English language pack for: In the next window, select Language packs tab, tick the English language and then accept changes by clicking Modify button (right bottom corner).
You could modify the following file:
c:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ItemTemplates\CSharp\Code\1033\Class.zip
It contains the template used when you add a new class. Inside the same folder you also have the template for interfaces: Interface.zip
so that they are public by default. IIRC a restart of VS is necessary to pick the changes.
You can create your own template by putting a file in C:\Users\you\Documents\Visual Studio 2010\Templates\ItemTemplates\Visual C#
.
For example, you can put "publicclass.cs" with this content :
using System; using System.Collections.Generic; $if$ ($targetframeworkversion$ >= 3.5)using System.Linq; $endif$using System.Text; namespace $rootnamespace$ { public class $safeitemrootname$ { } }
In order to avoid the class dialog, you can use the smart tag. Anywhere you would to use an inexisting class, simply type the class name, and press AltShiftF10 to popout the "generate class" menu.
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