class Form1 : Form
{
public void enable()
{
//1st method which i want to call from another class
}
public void display()
{
//2nd method which i want to call from another class
}
}
class Buffer : signal
{
protected override Analyse()
{
//from here i want to call two functions in form class
}
}
这是我的代码看起来像任何人请回复这个步骤.........
答案 0 :(得分:1)
创建Buffer类时,必须将引用传递给Form1的实例,然后才使用该实例。示例代码:
class Form1 : Form
{
public void InitBuffer()
{
Buffer b = new Buffer(this);
...
}
public void enable()
{
//1st method which i want to call from another class
}
public void display()
{
//2nd method which i want to call from another class
}
}
class Buffer : signal
{
private Form1 form;
public Buffer(Form1 parent)
{
form = parent;
}
protected override Analyse()
{
form.enable();
form.display();
}
}
你无法抓住Form1的真实实例。