Excuse the incredibly silly question but im new to C# . I just can’t figure out how to use classes from one Project in another Project.
Lets say I want to take a string from Project1 to Project2 and have Project2 print said string .
I reference Project2 from Project1 with the “add reference” menu , then I add “using Project2” and then I write this to trying and call "print" from "ClassA" in "Project2".
Project2.ClassA Classa = new Project2.ClassA();
Console.WriteLine(Classa.print);
but all i get are Error messages .
so can anyone please give a step by step explanation of EXACTLY why I need to do ?
Follow these instructions:
In the Solutions Explorer, right click on the project that you need to refer from.
Select "Add Reference". (latter versions i.e. beyond 2015; not exactly sure though; it should be "Add->Reference". Right click on References and select Add Reference also will do.)
Reference Manager - ProjectName dialog will appear.
In the left pane, expand Projects menu. That will populate a list of existing projects in the middle of the dialog.
Tick the checkbox before each project that you need to refer to.
Press OK.
Once done, you can use all the public and protected (given you are inheriting from an existing one) in the project that you have referred to. Make sure you add using NameSpace.Class
on the imports list.