程序这样写的namespace _007_B
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} public int num;
public string currentStation1;
public char[] changeStation = new char[5];
public bool isReached; public void Form1_Load(object sender, EventArgs e)
{
button1.Left = (this.Width - button1.Width) / 2;
Init();
} public void Init()
{
Station[] stations = new Station[3996];
//在这里给数组的成员赋值
Find(stations);
} public void Find(Station[] stations)
{
label1.text=stations[0].Text;
}
}
}
编译的时候告诉我参数类型_007_B.Station[]比_007_B.Form1.Find(_007_B.Station[])方法的可见性低。这什么意思啊?我明天早上交作业,高手快来救救我吧,分全给你们了!
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} public int num;
public string currentStation1;
public char[] changeStation = new char[5];
public bool isReached; public void Form1_Load(object sender, EventArgs e)
{
button1.Left = (this.Width - button1.Width) / 2;
Init();
} public void Init()
{
Station[] stations = new Station[3996];
//在这里给数组的成员赋值
Find(stations);
} public void Find(Station[] stations)
{
label1.text=stations[0].Text;
}
}
}
编译的时候告诉我参数类型_007_B.Station[]比_007_B.Form1.Find(_007_B.Station[])方法的可见性低。这什么意思啊?我明天早上交作业,高手快来救救我吧,分全给你们了!
{
Station[] stations = new Station[3996];
//在这里给数组的成员赋值
string station = stations[0].Text;(如果这里已经赋完值了)
Find(station);
}public void Find(string station)
{
label1.text=station;
}
LZ试试这样行不行?
而_007_B.Form1.Find可见性为 public。
public void Init()
{
Station[] stations = new Station[3996];
//在这里给数组的成员赋值
Find(stations);
}这里吧 Station[] stations 拿出来变全局变量看看怎么样 ?Station[] stations ;
public void Init()
{
stations = new Station[3996];
//在这里给数组的成员赋值
Find(stations);
}
{
InitializeComponent();
} public int num;
public string currentStation1;
public char[] changeStation = new char[5];
public bool isReached;
大哥 麻烦你 把 构造 方变量申明后面 好不
有哪位高手能讲讲为什么要这样写,我这样写了之后生成的form对象里stations是什么类型的?是public还是private?
还有个问题,链接在下面,都没人来解答啊我加分了,高手来领分了!
http://topic.csdn.net/u/20070921/13/c21bb2c7-6b56-4827-9283-e96187e70595.html
因为你要向大家公开的东西不能是人家不想让你公开的东西。Station[] stations = new Station[3996];
这个stations 是个局部变量,没有什么public或者privatepublic void Find(Station[] stations)
这个stations是个参数,而Find是public的,所以Station也要是public的