Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change Project Namespace in Visual Studio

How can I change the project namespace in Visual Studio?

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

like image 504
user319854 Avatar asked May 20 '10 05:05

user319854


People also ask

Can we change namespace in C#?

You could put the caret on a namespace declaration in your C# code and press F2 on the keyboard. This should let you change the name of the namespace across the entire project, including the XAML files.

How do I Rename a namespace in Visual Studio 2017?

Set your cursor into the namespace and then hit F2 to rename (if F2 didn't work, try CTRL R + CTRL R or rightclick - rename). All related namespaces should be changed.

What is a namespace in Visual Studio?

Visual Studio assigns your project name as the default root namespace for all code in your project. For example, if your project is named Payroll , its programming elements belong to namespace Payroll . If you declare Namespace funding , the full name of that namespace is Payroll. funding .


2 Answers

You can change the default namespace:
-> Project -> XXX Properties...
On Application tab: Default namespace

Other than that:
Ctrl-H
Find: WindowsFormsApplication16
Replace: MyName

like image 168
Kyle Rosendo Avatar answered Oct 10 '22 20:10

Kyle Rosendo


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

Thanks to @Jimmy for this.

like image 39
Yasser Shaikh Avatar answered Oct 10 '22 20:10

Yasser Shaikh