The flow of code doesn't follow my logic, and my lists don't get the required output.
public static List<String> genericList;
public static List<String> List1;
in frmLoadCurrentForm():
List1 = new List<String>();
genericList = new List<String>();
Then, in various places (? buttons)
1 private void btn1_Click(object sender, EventArgs e)
2 {
3 genericList = List1.ToList();
4 call();
5 List1 = genericList.ToList();
6 }
private void call()
{
frmForm form = new frmForm();
for (int i = 0; i < genericList.Count(); i++)
form.lst.Items.Add(genericList.ElementAt(i));
form.Show();
//form updates genericList on exit with lst contents, tested
}
While stepping through my code, I put a breakpoint on line 5, and code goes to line 5 then 4 (and into the form), then doesn't go back to 5 - so my List1 doesn't get updated with what happens inside the call().
I don't understand this logic, or what to do about it.
I am using multiple lists and a single genericList so that I can use a complicated interface for multiple situations, and theoretically my logic seems valid...
At the exit from the form, genericList has the right info, List1 doesn't. Why ?
Edit: added declaration of lists
Edit: As I step through, the form will start rendering but will not finish until the code at the end of the button that called the method that created the form got executed. Which is even more odd, since the form instance is created in a method so it should be closed and disposed of at the end of the method...