public partial class Form1 : Form
{
public static ArrayList ar;
public Form1()
{
InitializeComponent();
ar = new ArrayList();
}
}
public class trends
{
public void _trends()
{
ArrayList _ar = Form1.ar;
}
}
------解决方案--------------------
//类:
public class Trends
{
private Form ff;
//带参数构造函数
public trends(Form ff)
{
this.ff = ff;
}
}
//主窗体
Form
//类的使用窗体
//该窗体可以取到主窗体Form的实例,这个百度都有
Form ff = xxxx;
Trends ts = new Trends(ff);
//原理是将窗体作为变量传递给类