Apache.NMS.Util.URISupport.CheckParenthesis C# (CSharp) Method

CheckParenthesis() public static method

public static CheckParenthesis ( String str ) : bool
str String
return bool
        public static bool CheckParenthesis(String str)
        {
            bool result = true;

            if(str != null)
            {
                int open = 0;
                int closed = 0;

                int i = 0;
                while((i = str.IndexOf('(', i)) >= 0)
                {
                    i++;
                    open++;
                }

                i = 0;
                while((i = str.IndexOf(')', i)) >= 0)
                {
                    i++;
                    closed++;
                }

                result = (open == closed);
            }

            return result;
        }