Change Project Namespace in Visual Studio

2019-01-17 02:03发布

How can I change the project namespace in Visual Studio?

The namespace is currently WindowsFormsApplication16, and I want the namespace to be MyName.

7条回答
爷、活的狠高调
2楼-- · 2019-01-17 02:38

Assuming this is for a C# project and assuming that you want to change the default namespace, you need to go to Project Properties, Application tab, and specify "Default Namespace".

Default namespace is the namespace that Visual studio sets when you create a new class. Next time you do Right Click > Add > Class it would use the namespace you specified in the above step.

查看更多
3楼-- · 2019-01-17 02:41

You can change the default namespace:

-> Project -> Properties -> Default Namespace

Other than that,

Ctrl-H - Find: WindowsFormsApplication16 Replace: MyName

查看更多
小情绪 Triste *
4楼-- · 2019-01-17 02:44

"Default Namespace textbox in project properties is disabled" Same with me (VS 2010). I edited the project file ("xxx.csproj") and tweaked the item. That changed the default namespace.

查看更多
SAY GOODBYE
5楼-- · 2019-01-17 02:46

Instead of Find & Replace, you can right click the namespace in code and Refactor -> Rename.

Thanks to @Jimmy for this.

查看更多
SAY GOODBYE
6楼-- · 2019-01-17 02:50

First)

  1. Goto menu: Project -> WindowsFormsApplication16 Properties/
  2. write MyName in Assembly name and Default namespace textbox, then save.

Second)

  1. open one old .cs file ( a class or a form)
  2. right click on WindowsFormsApplication16 in front of namespace, goto Refactor -> Rename .
  3. write MyName in New name textbox, in Rename Message Box.
  4. press Ok, then Apply
查看更多
太酷不给撩
7楼-- · 2019-01-17 02:59

Right click properties, Application tab, then see the assembly name and default namespace

查看更多
登录 后发表回答