How to Use a Class from One C# Project With Another C# Project

How to use a class from one C# project with another C# project

Simply add reference to P1 from P2

How to use a C# class in many projects inside the same solution

Create a Class Library project within your solution and put your shared classes in there (right click on your solution in the Solution Explorer, Add, New Project). Then for each of the projects that you want to access the classes from, right click on Dependencies, Add Project Reference and tick the Class Library project you created.

How to import a class from another project in Visual Studio 2013 Ultimate

in solution explorer, right click on your project and go to add ==> existing item, then browse to the path of your existing class.

Share common c# class between 2 projects but allow a project to make changes to it

Don't write a class. Write an interface. Then, by design, a class that depends on the interface can use any implementation of the interface.

Using an object from another project in Visual Studio

Your program class should normally be part of your GUI project (which also has the window class). Then in your GUI project you only have to reference the db (context) and not vice versa which removes the circular dependency.

Also, you call a constructor of MainWindow with a parameter db (instance of ProgramControl; entityContext) which is not in your code?!

how to use class of other project in a solution (internal)?

In visual studio you should have a "References" area in the Solution Explorer. Right click that and click "Add Reference..."

From here, it's just a matter of locating where you other code is on your machine.

Edit: Here is some additional information on DLLs, in case it helps you.



Related Topics



Leave a reply



Submit