Reputation: 321
In Visual Studio, in the Program.cs
class, I add using ConsoleApp2.Service;
and then i get access to the class and members of the class ClassService.cs
.
How do I do the same in LINQPad
?
Other word.
How to make logic:
I create a query `Program. linq'.
I'm creating a query 'ClassService. linq'.
I write the namespace ClassService.linq
in query Program.linq
.
Result:
i can implement the code in query Program.linq
:
ClassService slsservice = new ClassService();
slsservice.MyProperty = 32;
slsservice.Method1();
Question:
How do I access members of another query LINQPad?
Is it possible to implement this logic in LINQPad?
Code for LINQPad
Program.linq
void Main()
{
ClassService
slsservice = new ClassService();
slsservice.MyProperty = 32;
slsservice.Method1();
}
ClassService.linq
public void Main()
{
}
public class SubMyClass1
{
private int myVar;
public int MyProperty
{
get { return myVar; }
set { myVar = value; }
}
public void Method1()
{
// ... Arbitrary code ...
}
}
Code for Visual Studio
Program.cs
using ConsoleApp2.Service;
namespace ConsoleApp2
{
class Program
{
static void Main(string[] args)
{
ClassService classService = new ClassService();
classService.MyProperty = 32;
classService.Method1();
}
}
}
ClassService.cs
namespace ConsoleApp2.Service
{
public class ClassService
{
private int myVar;
public int MyProperty
{
get { return myVar; }
set { myVar = value; }
}
public void Method1()
{
}
}
}
Upvotes: 4
Views: 350
Reputation: 20921
#load
directive which must be at the top is to achieve that. You can refer to the page. I have made a tad presentation as below.
Upvotes: 7