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

  1. In the ‘Solution Explorer’ tree, expand the P2 project, right-click (Shift+F10) the ‘Dependencies’ node and select ‘Add Project Reference…’.
  2. On the ‘Add Reference’ dialog, select your P1 project.
  3. If you are using namespaces then you will need to import the namespaces for your P1 types by adding ‘using’ statements to your files in P2.

Note that the types in P1 that you wish to access directly must have a sufficient access level: typically this means they must be made public.


Note: If you are working on an older project (e.g. .NET Framework) you may not have the ‘Dependencies’ node. In which case right-click the project and select ‘Add Reference’ from the menu and then ensure the ‘Projects’ tab is selected on the left.

Leave a Comment