4

Whenever I create a C# class in Visual Studio it has the following lines at the beginning of file:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

I want it to have other namespaces there by default when I create a new C# class. how can I do that?

Bizhan
  • 16,157
  • 9
  • 63
  • 101
  • 1
    You can edit the [Template Files](http://stackoverflow.com/questions/2072687/how-do-i-edit-the-visual-studio-templates-for-new-c-sharp-class-interface) – Kurubaran Mar 04 '14 at 10:19
  • Thanks. Class template was in C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\ItemTemplates\CSharp\Code\1033\Class – Bizhan Mar 04 '14 at 10:35

1 Answers1

4

Create a template for visual studio:

http://msdn.microsoft.com/en-us/library/6db0hwky(v=vs.90).aspx

EDIT: You can modify an existing template by loading it up, making the changes you require and then using the export template option (in the file menu) and follow the wizard through selecting the options you require.

Further update: to see the contents of c# class template look in:

C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\ItemTemplates\CSharp\Code\1033\Class

For VS2012 only

BenM
  • 4,218
  • 2
  • 31
  • 58
  • Is it possible to modify an existing template? where can I find these files? – Bizhan Mar 04 '14 at 10:19
  • Yep, simply load up an existing project, make any changes you need to the using directives, click on file -> Export Template(VS2010, not sure about other versions) and select project template then follow the wizard through. – BenM Mar 04 '14 at 10:21
  • Thanks that was easier than expected:) – Bizhan Mar 04 '14 at 10:31