1.
public class FormA : System.Windows.Forms.Form
{
public static string GetName()
{
return "Forma";
}
}
public class FormB : System.Window.Forms.Form
{
FormA formA = new FormA();
string name = formA.GetName();
}2.
public class FormA : System.Window.Forms.Form
{
public delegate void MyDelegateHandel(string message);
public event MyDelegateHandel MyEvent; public FormA()
{
} protected override void OnLoad(EventArgs e)
{
if (MyEvent != null)
MyEvent("FormA");
base.OnLoad(e);
}
}public class FormB : System.Window.Forms.Form
{
public FormB ()
{
FormA forma = new FormA();
forma.MyEvent += new FormA.MyDelegateHandel(forma_MyEvent);
forma.Show();
forma.Dispose();
} void forma_MyEvent(string message)
{
MessageBox.Show(message);
}
}
public class FormA : System.Windows.Forms.Form
{
public static string GetName()
{
return "Forma";
}
}
public class FormB : System.Window.Forms.Form
{
FormA formA = new FormA();
string name = formA.GetName();
}2.
public class FormA : System.Window.Forms.Form
{
public delegate void MyDelegateHandel(string message);
public event MyDelegateHandel MyEvent; public FormA()
{
} protected override void OnLoad(EventArgs e)
{
if (MyEvent != null)
MyEvent("FormA");
base.OnLoad(e);
}
}public class FormB : System.Window.Forms.Form
{
public FormB ()
{
FormA forma = new FormA();
forma.MyEvent += new FormA.MyDelegateHandel(forma_MyEvent);
forma.Show();
forma.Dispose();
} void forma_MyEvent(string message)
{
MessageBox.Show(message);
}
}
找不到类型或命名空间名称“FormA”(是否缺少 using 指令或程序集引用)