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

I'm completely new to using Visual Studio 2013 Ultimate and C #, and I'm trying to figure out how easy it is to import a class existing in another project into a console application.

I have another project with a name Project1that contains a file CreditCard.cs. I tried the following to import a class CreditCard:

  • enter using Project1.CreditCard
  • go to Solution Explorer , and then find the “Links” that I could not find in order to try to include the class as an imported class.

Can someone point me in the right direction or tell me how I can import a class in C #?

+4
source share
3 answers

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

+6
source

You right-click on the project (not the solution) that you want to have a link to. So, click on your new project, select "Add" | Links --- then in the dialog box select “Solution” on the left and find the “Credit Card” project and add it. It will add a link, and then you can use "Use" in your code.

+3
source

, ? , (Project1) (Project2), :

  • (Project2),
  • → →
  • Specify the project (Project1) that you want to add and click OK

Now in your project (Project2) you can "use Project1 (the name of your project)" or "using Project1.FolderName" if your class is in the folder to use this class, and then:

CreditCard creditCard = new CreditCard();
0
source

All Articles