我有以下代码:
public Form1()
{
InitializeComponent();
string strRadio = Utils.ReadFile(strTemp + @"\rstations.txt");
string[] aRadio = strRadio.Split(new string[] { "#" }, StringSplitOptions.RemoveEmptyEntries);
for (int i = 0; i < aRadio.Length; i += 2)
{
listBox.Items.Add(aRadio[i]);
}
}
private void listBox_SelectedIndexChanged(object sender, EventArgs e)
{
int index = listBox.SelectedIndex;
MessageBox.Show(aRadio[(index+1)]);
}
现在的错误是 The name 'aRadio' does not exist in the current context
,它来自于MessageBox.Show(aRadio[(index+1)]);
。我需要将aRadio
声明为公共的或者其他吗?如果需要,应该怎么做?
Path.Combine
。 - user