我想知道如何去引用每个数据循环,以便我可以将它传递给文本框。如果有 5 个循环,我该如何选择仅在主窗体的文本框中显示第三个循环?我添加了 m_intNumberofEvents 来计算它执行的循环数,但我不知道如何连接它,或者它是否有效。请帮忙!谢谢!
public List<Event> ExtractData(DateTime dtmDay)
{
int intChosenDay = dtmDay.Day;
m_intNumberofEvents = 0;
int intFileDay;
StreamReader textIn = new StreamReader(
new FileStream(path, FileMode.OpenOrCreate, FileAccess.Read));
//create the list
List<Event> events = new List<Event>();
string[] lines = File.ReadAllLines(path);
for (int index = 4; index < lines.Length; index += 5)
{
Event special = new Event();
special.Day = Convert.ToInt32(lines[index - 4]);
special.Time = (lines[index - 3]);
special.Price = Convert.ToDouble(lines[index - 2]);
special.StrEvent = lines[index - 1];
special.Description = lines[index];
events.Add(special);
m_intNumberofEvents++;
}
textIn.Close();
return events;
}