/// <summary> /// Clears current stack and adds everyitem to new stack /// </summary> /// <param name="radioButton"></param> public void SwitchStack(RadioButton radioButton) { switch (array) { case "ArrayStack": arrayStack.Clear(); break; case "ListStack": listStack.Clear(); break; case "MyListStack": myListStack.Clear(); break; default: break; } if (radioButton.Checked) { // Set new value to array array = radioButton.Text; // Fill stack with list switch (array) { case "ArrayStack": foreach (double item in listBoxValues) { arrayStack.Add(item); } break; case "ListStack": foreach (double item in listBoxValues) { listStack.Add(item); } break; case "MyListStack": foreach (double item in listBoxValues) { myListStack.Add(item); } break; default: break; } } }
// Explained in Stack class public override void Clear() { if (next == null && item == null) { return; } else { item = null; if (next != null) { next.Clear(); } } }