当在组合框中选择第一个选项时,我希望我的程序从前一个选项中减去连续的字符串。
EG。第二个值来自第一个,第三个来自第二个,第四个来自第三个,依此类推至40个。
我尝试了这个,但它只是读取了没有计算的实际列表
private void comboBoxOptions_SelectedIndexChanged(object sender, EventArgs e)
{
if (comboBoxOptions.SelectedIndex == 0)
{
string population = @"U:\My Documents\4.Bus App\Assignment 5\irishPopulation.txt";
const int SIZE = 40;
int[] numbers2 = new int[SIZE];
int index = 0;
StreamReader inputFile = new StreamReader(population);
while (index < numbers2.Length && !inputFile.EndOfStream)
{
numbers2[index] = int.Parse(inputFile.ReadLine());
index++;
}
textBoxAnswer.Text = File.ReadAllText(@"U:\My Documents\4.Bus App\Assignment 5\irishPopulation.txt"); //Puts file in textbox
textBoxAnswer.ScrollBars = ScrollBars.Vertical; //Gives text a scroll bar
inputFile.Close();
}