public T Pop() { if (IsEmpty()) { throw new Exception("Stack is empty, nothing to pop."); } var nextStackItem = _stackItem.NextItem; var valueToReturn = _stackItem.ObjectValue; _stackItem = nextStackItem; return(valueToReturn); }
public MyStackItem(T value, MyStackItem <T> nextStackItem) { ObjectValue = value; NextItem = nextStackItem; }
public void Push(T data) { var stackItem = new MyStackItem <T>(data, _stackItem); _stackItem = stackItem; }