Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS2010: Use namespace from another project within the solution?

I have two projects within a single solution in Visual Studio 2010. These projects are called Project1 and Project2. Within these projects, two namespaces are defined, Namespace1 and Namespace2, respectively.

Inside some code within Namespace2, I'd like to use some structs, classes, etc. which I've defined in Namespace1. Is there any way to do this?

like image 390
Adam S Avatar asked Dec 11 '10 13:12

Adam S


People also ask

How do I automatically add a namespace in Visual Studio?

If you are adding a new class in your code then you may need to add the correspondence namespaces. To do it, you may either manually type the Using Namespace or you just right click on the class name and select Resolve > Namespace. But using “Ctrl+.” you can automatically add the namespace in your code.


1 Answers

Yes, add a reference to Project1 from Project2. Right-click the project, choose "Add References" then from the "Projects" tab, choose Project1.

like image 143
Dean Harding Avatar answered Oct 11 '22 09:10

Dean Harding