using System;
using System.Collections.Generic;

class StackExample<T>
{
    private List<T> items = new List<T>();

    public void Push(T obj)
    {
        items.Add(obj);
    }

    public T Pop()
    {
        if (items.Count == 0)
        {
            throw new InvalidOperationException("The stack is empty...");
        }

        int lastIndex = items.Count - 1;
        T poppedItem = items[lastIndex];
        items.RemoveAt(lastIndex);
        return poppedItem;
    }

    public void Clear()
    {
        items.Clear();
    }
}

class Program
{
    static void Main(string[] args)
    {
        StackExample<int> stack1 = new StackExample<int>();

        stack1.Push(11);
        stack1.Push(22);
        stack1.Push(33);

        Console.WriteLine("Popped " + stack1.Pop()); // 33

        stack1.Push(44);

        Console.WriteLine("Popped  " + stack1.Pop()); // 44

        stack.Clear();
    }
}

By davs