Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

How can I change the default namespace used when you create a new class in Visual Studio?

Background: My solution has a project MyCompany.MyProject.Domain in which I have a folder "Model Base (Linq)" with a subfolder "Extensions" where I keep all partial class extensions.

MyCompany.MyProject.Domain
   + Model Base (Linq)
        + Extensions
           - Order.cs
           - Trace.cs 

When I create a new .cs file in there, the namespace gets set to MyCompany.MyProject.Domain.Model_Base\_\_Linq\_\_.Extensions, I only want it to be MyCompany.MyProject.Domain.Model though.

How can I change this default behavior?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
195 views
Welcome To Ask or Share your Answers For Others

1 Answer

There are 4 schools of thought here:

  • edit it manually
  • live with it
  • change the class template (or export a second class template)
  • create the file outside the sub-directory, then drag it in

I tend to use the 4th; it is quicker than editing, and less hassle than changing the templates


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...