public T Pop() { StackElement <T> temp = startElement; if (startElement == null) { throw new NullReferenceException(); } else { startElement = startElement.next; return(temp.value); } }
public MyStack() { startElement = null; }
public void Push(T value) { StackElement <T> element = new StackElement <T>(value, startElement); startElement = element; }
public StackElement(T value, StackElement <T> next) { this.value = value; this.next = next; }