visual-studio 在 Visual Studio 中更改项目命名空间
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2871314/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Change Project Namespace in Visual Studio
提问by user319854
How can I change the project namespace in Visual Studio?
如何在 Visual Studio 中更改项目命名空间?
The namespace is currently WindowsFormsApplication16, and I want the namespace to be MyName.
命名空间当前为WindowsFormsApplication16,我希望命名空间为MyName。
回答by Kyle Rozendo
You can change the default namespace:
-> Project-> XXX Properties...
On Application tab: Default namespace
您可以更改默认命名空间:
-> Project->XXX Properties...
在应用程序选项卡上:默认命名空间
Other than that:Ctrl-H
Find: WindowsFormsApplication16
Replace: MyName
除此之外:Ctrl-H
查找:WindowsFormsApplication16
替换:MyName
回答by Yasser Shaikh
回答by Igor Zevaka
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".
假设这是针对 C# 项目并假设您要更改默认命名空间,则需要转到“项目属性”、“应用程序”选项卡,并指定“默认命名空间”。
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.
默认命名空间是 Visual Studio 在创建新类时设置的命名空间。下次您执行 Right Click > Add > Class 时,它将使用您在上述步骤中指定的命名空间。
回答by Gary Huckabone
"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.
“项目属性中的默认命名空间文本框已禁用”与我相同(VS 2010)。我编辑了项目文件(“xxx.csproj”)并调整了项目。这改变了默认命名空间。
回答by Szybki
Just right click on the name you want to change (this could be namespace or whatever else) and select Refactor->Rename...
只需右键单击要更改的名称(可以是命名空间或其他任何名称),然后选择Refactor->Rename...
Enter new name, leave location as [Global Namespace], check preview if you want and you're done!
输入新名称,将位置保留为 [全局命名空间],如果需要,请检查预览并完成!
回答by Jason Jong
Right click properties, Application tab, then see the assembly name and default namespace
右键单击属性,应用程序选项卡,然后查看程序集名称和默认命名空间
回答by PedPak
First)
第一的)
- Goto menu: Project-> WindowsFormsApplication16 Properties/
- write MyNamein Assembly nameand Default namespacetextbox, then save.
- 转到菜单:项目-> WindowsFormsApplication16 属性/
- 在程序集名称和默认命名空间文本框中写入 MyName,然后保存。
Second)
第二)
- open one old .csfile ( a classor a form)
- right click on WindowsFormsApplication16in front of namespace, goto Refactor -> Rename.
- write MyNamein New nametextbox, in Rename Message Box.
- press Ok, then Apply
- 打开一个旧的.cs文件(一个类或一个表单)
- 右键单击 命名空间前面的WindowsFormsApplication16,转到Refactor -> Rename。
- 写MYNAME在新名称的文本框,在重命名的消息框。
- 按Ok,然后应用

