Skip to content

Instantly share code, notes, and snippets.

@rsotto
Last active November 28, 2017 19:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rsotto/2b0818cb3279e065d9fc6e18a89d2950 to your computer and use it in GitHub Desktop.
Save rsotto/2b0818cb3279e065d9fc6e18a89d2950 to your computer and use it in GitHub Desktop.
/// <summary>
/// Initializes a new instance of the MyStack&lt;T&gt; class with an empty stack.
/// </summary>
public MyStack()
{
_myStack = new Stack<T>();
}
/// <summary>
/// Removes and returns an element at the top of MyStack&lt;T&gt;.
/// </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