我有我想从我的主类调用的代码:
public void Display()
{
Form1 z = new Form1();
z.listBox1.Items.Add("=============================Summary=============================\n\n");
z.listBox1.Items.Add("1st: "+Num1+" 2nd #: "+Num2);
z.listBox1.Items.Add("\n"+" 3rd #: "+Num3+" 4th #: "+Num4);
z.listBox1.Items.Add("\n"+" 5th #: "+Num5);
z.listBox1.Items.Add("\n" + "SUM: " + Sum + " DIFF: " + Sub + "\n" + " PROD: " + Multiply + " QOU: " + Divide);
// result = ("=============================Summary=============================\n\n 1st #: " + Num1 + " 2nd #: " + Num2 + "\n 3rd #: " + Num3 + " 4th : " + Num4 + "\n 5th #: " + Num5 + "\n" + "SUM: " + Sum + " DIFF: " + Sub + "\n" + " PROD: " + Multiply + " QOU: " + Divide);
}
在我的主类中,我尝试这样做:并且我还尝试将修饰符更改为公共,这样我就可以使用我的子类中的列表框..
Class1 zz = new Class1();
zz.Display();
我的问题是如何Display
从子类调用主类?我是 C# 的新手,非常感谢您的帮助。:D