1

In Visual Studio 2012, when I add a new class to my project, it automatically comes with some namespaces (System, System.Collections.Generic, System.Linq and System.Text).

I always use System.Data and I want this namespace in all my classes. My question is this: How can I configure that all my new classes already comes with that namespace in top of it?

I'm sorry if my question wasn't clear enough. Thanks in advance!

Everton Lenger
  • 1,446
  • 2
  • 17
  • 32
  • 1
    FYI. If you're referring to the `using System;` lines at the top of the file, those are `namespaces`, not dll/libraries. One dll/library (that gets referenced at the project level) could contain many namespaces. – George Duckett Jan 22 '14 at 12:45
  • 3
    Duplicate of [How do I edit the Visual Studio templates for new C# class/interface?](http://stackoverflow.com/questions/2072687/how-do-i-edit-the-visual-studio-templates-for-new-c-sharp-class-interface). – CodeCaster Jan 22 '14 at 12:46
  • Thanks for the info George, I really was in doubt about that name.. But, just to be clear, the only way to do what I want is editing the template for new classes? – Everton Lenger Jan 22 '14 at 12:56

1 Answers1

0

actually it depends upon the template you are using that which namespace need to import or not. There is not direct way to do this.

Change the existing template.

goto the location

%ProgramFiles%\Microsoft Visual Studio 9.0\Common7\IDE\itemtemplatescache\CSharp\Code\1033\Class.zip

or

%ProgramFiles%\Microsoft Visual Studio 10.0\Common7\IDE\itemtemplatescache\CSharp\Code\1033\Class.zip

or if you are still confuse search the folder Class.zip and open it and change the template. :)

Deepak Sharma
  • 4,124
  • 1
  • 14
  • 31
  • Well, I changed the template in the ItemTemplates instead of ItemTemplatesCache and it works. Is there any difference about those two folders? – Everton Lenger Jan 22 '14 at 13:17
  • oh hmm actually installing the more thn one VS confused me.. :) well its working as u want right?? and let me tell u, you can design ur own template so whenever u go to add an item it will show new option like "MyClass" which have the namespace as u want. – Deepak Sharma Jan 22 '14 at 16:22
  • and yes if it resolved u prob then why didnot u accepted this answer?? :) it would be nice and i will be happy if u accept my answer and like it.. :) – Deepak Sharma Jan 22 '14 at 16:23
  • I just wanted to know if would have any problem with that, but I'll keep it that way and we'll see if there is a problem or not.. And yes, I accept your answer.. =) – Everton Lenger Jan 22 '14 at 16:56
  • no not at all.. you will not face any problem with this.. i mean by changing template. but remember u change it in correct manner. – Deepak Sharma Jan 23 '14 at 07:04