The following program verifies if a provided string contains properly balanced parentheses. The program uses a stack to analyze the input string.

using System;

namespace ConsoleTest
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = new Stack();

            string parentheses = args[0];

            bool balanced = true;
            foreach (char ch in parentheses)
            {
                if (ch == '{' || ch == '[' || ch == '(')
                    s.Push(ch);
                else
                {
                    char r = s.Pop();
                    if ((ch == ')' && r != '(') ||
                        (ch == ']' && r != '[') ||
                        (ch == '}' && r != '{'))
                    {
                        balanced = false;
                        break;
                    }
                }
            }

            Console.WriteLine("Parentheses are " + (balanced ? "balanced" : "not balanced") + ".");
            Console.ReadKey();
        }

        class Stack where T : struct
        {
            private Node first; // the top of stack
            private int N; // stack size

            public bool IsEmpty { get { return first == null; } }
            public int Size { get { return N; } }

            public void Push(T item)
            {
                Node oldFirst = first;
                first = new Node();
                first.Item = item;
                first.Next = oldFirst;

                ++N;
            }

            public T Pop()
            {
                T item = first.Item;
                first = first.Next;

                --N;

                return item;
            }

            private class Node
            {
                public T Item { get; set; }
                public Node Next { get; set; }

                public override string ToString() { return Item.ToString(); }
            }
        }
    }
}

Sample output:

[()]{}{[()()]()} are balanced.

[(]) are not balanced.

[()]{({}[{}])}{()[()[({})]]({[]}()())}() are balanced.