I'm not sure what your situation is, but if you don't have a reference to myForm, why or when you want to call some non-static method defined in MyForm?
If, on the other hand, you have a link to it, just make it MyFunctionpublic and call it normally:
class Program
{
MyForm myForm = new MyForm();
....
myForm.MyFunction();
}
public partial class MyForm: Form
{
....
public int MyFunction() {...}
}
You can also make it static and add a reference to the MyForm instance in the function arguments if there was any practical reason for this.
public partial class MyForm: Form
{
....
public static int MyFunction(MyForm myForm) {...}
}
source
share