private static void PopLastElement(MyStackWithLinkedList obj) { int number; number = obj.Pop(); if (number != int.MinValue) { Console.WriteLine("Popped {0}", number); } }
private static void PrintTheLastElement(MyStackWithLinkedList obj) { int number; number = obj.Peek(); if (number != int.MinValue) { Console.WriteLine("Last element {0}", number); } }
private static void Main() { var obj = new MyStackWithLinkedList(); obj.Push(8); PopLastElement(obj); PopLastElement(obj); PrintTheLastElement(obj); obj.Push(10); obj.Push(9); PrintTheLastElement(obj); }