How does stack.pop () work? I want to implement the Undo function
I write in the Stack text from the form when you change the text
private void Output_tb_TextChanged(object sender, EventArgs e) { undoActions.Push(output_tb.Text); } Here I return the text when you click Undo
private void Undo_bt_Click(object sender, EventArgs e) { if (undoActions.Count<1) { return; } output_tb.Text = undoActions.Pop(); But the previous state of the text appears only when the second click on the Undo button. Why it happens?