Ну, List<T>
не имеет GetCC()
, а Line
;что-то вроде этого:
private void startingStation_SelectedIndexChanged(object sender, EventArgs e) {
//TODO: you have to obtain Line instance here
Line line = new Line();
// In order to avoid constant redrawing: we want repaint combobox once,
// after all items being inserted
startingStation.BeginUpdate();
try {
// It is line (not List<T>) that provides GetCC() method
foreach (Station station in line.GetCC()) {
// String interpolation - $"..." is more readable than concatenation
startingStation.Items.Add($"{station.Number} {station.Desc}");
}
}
finally {
startingStation.EndUpdate();
}
}
Редактировать: Вы можете улучшить GetCC()
реализацию с помощью Linq (которая специально разработана для запросов):
using System.Linq;
...
class Line : Station {
...
public List<Station> GetCC() {
return file
.Where(item => item.Number.Contains("CC"))
.ToList();
}
...
}