-
-
Save rsotto/2b0818cb3279e065d9fc6e18a89d2950 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Initializes a new instance of the MyStack<T> class with an empty stack. | |
/// </summary> | |
public MyStack() | |
{ | |
_myStack = new Stack<T>(); | |
} | |
/// <summary> | |
/// Removes and returns an element at the top of MyStack<T>. | |
/// </summary> | |
/// <returns>The element returned.</returns> | |
/// <exception cref="System.InvalidOperationException">Thrown when stack is empty.</exception> | |
public T Pop() | |
{ | |
if (IsEmpty) throw new InvalidOperationException("Invalid pop operation due to empty stack."); | |
return _myStack.Pop(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment