Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calling methods from different Projects in one Solution

There are 3 Projects in 1 Solution. Main manipulations I make from the main file in the 1st Project. However I need to call methods and use classes from the 3rd Project. For example:

– 3rd Project has:

public DataClasses1DataContext() :     base(global::WindowsFormsApplication1.Properties.Settings.Default.mediaBorshchConnectionString, mappingSource)
 { OnCreated(); } 

What is the right way to call it from my 1st Project?

DataClasses1DataContext borshch = new DataClasses1DataContext()
like image 285
user1316502 Avatar asked Jun 19 '12 00:06

user1316502


People also ask

How do you call another project from a project in the same solution?

Step 1: Make a reference from Project A to B. Step 2: Make Project B's Program. cs Public by adding the word "public" in front of "class Program". Step 3) Make a public method returnPath().

How do you call a method from one project to another in C#?

To do this, right-click on your project, select "Add Reference," then select the project in your solution. Once your main project references the 3rd project, then you can access its public types. Can't believe how difficult some of the other answers made this. Thank you!


1 Answers

You need to add a reference to the 3rd project in your 1st project. To do this, right-click on your project, select "Add Reference," then select the project in your solution. Once your main project references the 3rd project, then you can access its public types.

like image 123
Jacob Avatar answered Sep 18 '22 11:09

Jacob