climivin
climivin

Reputation: 321

How do I access members of another query LINQPad?

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:


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()
        {
 
        }
 
    }
}

Picture enter image description here

Upvotes: 4

Views: 350

Answers (1)

#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.

enter image description here

Upvotes: 7

Related Questions