public bool CheckBrackets(string sampleBrackets)
        {
            MyDynamicStack <char> myDynamicStack = new MyDynamicStack <char>();

            char[] bracketChars = sampleBrackets.ToCharArray();

            foreach (var bracketChar in bracketChars)
            {
                if (bracketChar == '(' || bracketChar == '{' || bracketChar == '[')
                {
                    myDynamicStack.Push(bracketChar);
                }
                else
                {
                    if (bracketChar == ')' && myDynamicStack.Peek() == '(')
                    {
                        myDynamicStack.Pop();
                    }
                    else if (bracketChar == '}' && myDynamicStack.Peek() == '{')
                    {
                        myDynamicStack.Pop();
                    }
                    else if (bracketChar == ']' && myDynamicStack.Peek() == '[')
                    {
                        myDynamicStack.Pop();
                    }
                    else
                    {
                        return(false);
                    }
                }
            }

            if (myDynamicStack.IsEmpty())
            {
                return(true);
            }

            return(false);
        }
        } // "-+2*34/[16]^23" iki ve ikiden büyük basamaklı sayılar [] parantezler arasına yazılmalıdır.

        public double EvaluatePostfixExpression(StringBuilder evaluateString)
        {
            StringBuilder           appendBuilder = new StringBuilder();
            MyDynamicStack <double> stack         = new MyDynamicStack <double>();
            int length = evaluateString.Length;

            for (int i = 0; i < length; i++)
            {
                string c = evaluateString[i].ToString();

                if (char.IsDigit(c, 0))
                {
                    double term = Convert.ToSByte(c);//Taranan ifadeler rakam olacağından SByte işimizi görecektir.
                    stack.Push(term);
                }
                else if (c == "[")//[] parantez ifadesi negatif ifade veya iki ve üstü haneli sayı olduğundan parantez sonuna kadar tarama yapılır.
                {
                    char join = evaluateString[++i];
                    while (join != ']')
                    {
                        appendBuilder.Append(join);
                        join = evaluateString[++i];
                    }

                    stack.Push(Convert.ToDouble(appendBuilder.ToString()));
                    appendBuilder.Clear();
                }
                else
                {
                    switch (c) //Postfix sırası Stack durumu second-first!
                    {
                    case "^":
                        double first  = stack.Pop();
                        double second = stack.Pop();
                        double result = Math.Pow(second, first);
                        stack.Push(result);
                        break;

                    case "*":
                        first  = stack.Pop();
                        second = stack.Pop();
                        result = first * second;
                        stack.Push(result);
                        break;

                    case "/":
                        first  = stack.Pop();
                        second = stack.Pop();
                        result = second / first;
                        stack.Push(result);
                        break;

                    case "+":
                        first  = stack.Pop();
                        second = stack.Pop();
                        result = second + first;
                        stack.Push(result);
                        break;

                    case "-":
                        first  = stack.Pop();
                        second = stack.Pop();
                        result = second - first;
                        stack.Push(result);
                        break;
                    }
                }
            }

            return(stack.Pop());
        }
        public double EvaluatePrefixExpression(string evaluateString)
        {
            StringBuilder           appendBuilder = new StringBuilder();
            MyDynamicStack <double> stack         = new MyDynamicStack <double>();
            int length = evaluateString.Length;

            for (int i = length - 1; i >= 0; i--)
            {
                string c = evaluateString[i].ToString();

                if (char.IsDigit(c, 0))
                {
                    double term = Convert.ToSByte(c);//Taranan ifadeler rakam olacağından SByte işimizi görecektir.
                    stack.Push(term);
                }
                else if (c == "]")//[] parantez ifadesi negatif ifade veya iki ve üstü haneli sayı olduğundan parantez sonuna kadar tarama yapılır.
                {
                    char join = evaluateString[--i];
                    while (join != '[')
                    {
                        appendBuilder.Insert(0, join);
                        join = evaluateString[--i];
                    }

                    stack.Push(Convert.ToDouble(appendBuilder.ToString()));
                    appendBuilder.Clear();
                }
                else
                {
                    switch (c)
                    {
                    case "^":
                        double first  = stack.Pop();
                        double second = stack.Pop();
                        double result = Math.Pow(first, second);
                        stack.Push(result);
                        break;

                    case "*":
                        first  = stack.Pop();
                        second = stack.Pop();
                        result = first * second;
                        stack.Push(result);
                        break;

                    case "/":
                        first  = stack.Pop();
                        second = stack.Pop();
                        result = first / second;
                        stack.Push(result);
                        break;

                    case "+":
                        first  = stack.Pop();
                        second = stack.Pop();
                        result = first + second;
                        stack.Push(result);
                        break;

                    case "-":
                        first  = stack.Pop();
                        second = stack.Pop();
                        result = first - second;
                        result = second == 0 && evaluateString[0] == '-' ? -1 * result : result;    //Son ifade - olursa ve Stack te tek bir değer varsa, sayı negatif
                        stack.Push(result);
                        break;
                    }
                }
            }

            return(stack.Pop());
        } // "-+2*34/[16]^23" iki ve ikiden büyük basamaklı sayılar [] parantezler arasına yazılmalıdır.
        public StringBuilder PrefixToInfix(StringBuilder stringBuilder)
        {
            StringBuilder           appendBuilder = new StringBuilder();
            MyDynamicStack <string> stack         = new MyDynamicStack <string>();
            int length = stringBuilder.Length;

            for (int i = length - 1; i >= 0; i--)
            {
                string c = stringBuilder[i].ToString();

                if (char.IsLetterOrDigit(c, 0))
                {
                    stack.Push(c);
                }
                else if (c == "]")
                {
                    char join = stringBuilder[--i];
                    while (join != '[')
                    {
                        appendBuilder.Insert(0, join);
                        join = stringBuilder[--i];
                    }

                    string result = appendBuilder.ToString();
                    result = "[" + result + "]";
                    stack.Push(result);
                    appendBuilder.Clear();
                }
                else
                {
                    switch (c)
                    {
                    case "^":
                        string first  = stack.Pop();
                        string second = stack.Pop();
                        string result = first + "^" + second;
                        stack.Push(result);
                        break;

                    case "*":
                        first  = stack.Pop();
                        second = stack.Pop();
                        result = first + "*" + second;
                        stack.Push(result);
                        break;

                    case "/":
                        first  = stack.Pop();
                        second = stack.Pop();
                        result = first + "/" + second;
                        stack.Push(result);
                        break;

                    case "+":
                        first  = stack.Pop();
                        second = stack.Pop();
                        result = second != null ? "{" + first + "+" + second + "}" : first;
                        stack.Push(result);
                        break;

                    case "-":
                        first  = stack.Pop();
                        second = stack.Pop();
                        result = second != null ? "{" + first + "-" + second + "}" : first;
                        stack.Push(result);
                        break;
                    }
                }
            }

            return(appendBuilder.Append(stack.Pop()));
        }
        public StringBuilder InfixToPostfixConverter(StringBuilder stringBuilder)
        {
            MyDynamicStack <string> stack         = new MyDynamicStack <string>();
            StringBuilder           appendBuilder = new StringBuilder();
            StringBuilder           tempBuilder   = new StringBuilder();
            int length = stringBuilder.Length;

            for (int i = 0; i < length; i++)            //String üzerinde soldan-sağa dolaşılır.
            {
                string c = stringBuilder[i].ToString(); //Stack string seçildiğinden gelen char ifadesi string'e dönüştürülür.

                if (char.IsLetterOrDigit(c, 0))
                {
                    appendBuilder.Append(c);
                }
                else if (c == "^" || c == "(" || c == "{") //Parantez ve ^ önceliği için koşullar, [ ] parantezi iki ve üstü haneli sayıları temsilen kullanılmıştır.
                {
                    stack.Push(c);
                }
                else if (c == ")" || c == "}")
                {
                    while (stack.Peek() != null && stack.Peek() != "(" && stack.Peek() != "{")
                    {
                        appendBuilder.Append(stack.Pop());
                    }

                    stack.Pop();
                }
                else if (c == "[") //Sağdan sola tarama yapılır, [ ifadesine rastlanması halinde döngüye girilir, ta ki ] ifadesine gelene değin.
                {
                    char join = stringBuilder[++i];
                    while (join != ']')
                    {
                        tempBuilder.Append(join);//[ifade] ifade geçici olarak tempBuilder içinde tutulur.
                        join = stringBuilder[++i];
                    }

                    appendBuilder.Append("[" + tempBuilder.ToString() + "]");//İki ve üstü haneli sayılar [] parantezleri arasına yazılır.
                    tempBuilder.Clear();
                }
                else
                {
                    if (CheckRank(c) > CheckRank(stack.Peek()))
                    {
                        stack.Push(c);
                    }
                    else
                    {
                        while (stack.Peek() != null && CheckRank(c) <= CheckRank(stack.Peek()))
                        {
                            appendBuilder.Append(stack.Pop());
                        }
                        stack.Push(c);
                    }
                }
            }

            while (stack.Peek() != null)
            {
                appendBuilder.Append(stack.Pop());
            }

            return(appendBuilder);
        }
        public string PrefixToInfix(string stringBuilder)
        {
            StringBuilder           appendBuilder = new StringBuilder();
            MyDynamicStack <string> stack         = new MyDynamicStack <string>();
            int length = stringBuilder.Length;

            for (int i = length - 1; i >= 0; i--)
            {
                string c = stringBuilder[i].ToString();

                if (char.IsLetterOrDigit(c, 0))
                {
                    stack.Push(c);
                }
                else if (c == "]") //Tersten tarama yapıldığı için karşılaşılan parantez "]" olur.
                {
                    char join = stringBuilder[--i];
                    while (join != '[')
                    {
                        appendBuilder.Insert(0, join); //Tarama sırası dikkate alınır, Insert işlemi terimi baştan ekler.
                        join = stringBuilder[--i];
                    }
                    string result = appendBuilder.ToString();
                    result = "[" + result + "]";
                    stack.Push(result);
                    appendBuilder.Clear();
                }
                else
                {
                    switch (c)
                    {
                    case "^":
                        string first  = stack.Pop();
                        string second = stack.Pop();
                        string result = first + "^" + second;
                        stack.Push(result);
                        break;

                    case "*":
                        first  = stack.Pop();
                        second = stack.Pop();
                        result = first + "*" + second;
                        stack.Push(result);
                        break;

                    case "/":
                        first  = stack.Pop();
                        second = stack.Pop();
                        result = first + "/" + second;
                        stack.Push(result);
                        break;

                    case "+":
                        first  = stack.Pop();
                        second = stack.Pop();
                        result = second != null ? "{" + first + "+" + second + "}" : first;
                        stack.Push(result);
                        break;

                    case "-":
                        first  = stack.Pop();
                        second = stack.Pop();
                        result = second != null ? "{" + first + "-" + second + "}" : first;
                        stack.Push(result);
                        break;
                    }
                }
            }

            return(stack.Pop());
        }
        public string PostfixToInfix(string stringBuilder)
        {
            StringBuilder           appendBuilder = new StringBuilder();
            MyDynamicStack <string> stack         = new MyDynamicStack <string>();
            int length = stringBuilder.Length;

            for (int i = 0; i < length; i++)
            {
                string c = stringBuilder[i].ToString();

                if (char.IsLetterOrDigit(c, 0))
                {
                    stack.Push(c);
                }
                else if (c == "[")
                {
                    char join = stringBuilder[++i];
                    while (join != ']')
                    {
                        appendBuilder.Append(join);
                        join = stringBuilder[++i];
                    }

                    string result = appendBuilder.ToString();
                    result = "[" + result + "]";
                    stack.Push(result);
                    appendBuilder.Clear();
                }
                else
                {
                    switch (c) // Stack sırasına göre işlemler düzenlenir, second^first , ab için stack sırasına dikkat edilir.
                    {
                    case "^":
                        string first  = stack.Pop();
                        string second = stack.Pop();
                        string result = second + "^" + first;
                        stack.Push(result);
                        break;

                    case "*":
                        first  = stack.Pop();
                        second = stack.Pop();
                        result = second + "*" + first;
                        stack.Push(result);
                        break;

                    case "/":
                        first  = stack.Pop();
                        second = stack.Pop();
                        result = second + "/" + first;
                        stack.Push(result);
                        break;

                    case "+":
                        first  = stack.Pop();
                        second = stack.Pop();
                        result = second != null?"{" + second + "+" + first + "}":first;   // Stack tek eleman içermesi durumunda koşullar.
                        stack.Push(result);
                        break;

                    case "-":
                        first  = stack.Pop();
                        second = stack.Pop();
                        result = second != null?"{" + second + "-" + first + "}":first;
                        stack.Push(result);
                        break;
                    }
                }
            }

            return(stack.Pop());
        }
        public StringBuilder InfixToPrefixConverter(StringBuilder stringBuilder)
        {
            MyDynamicStack <string> stack         = new MyDynamicStack <string>();
            StringBuilder           appendBuilder = new StringBuilder();
            StringBuilder           tempBuilder   = new StringBuilder();
            int length = stringBuilder.Length;

            for (int i = length - 1; i >= 0; i--)//Sondan başa doğru tarama yapılır.
            {
                string c = stringBuilder[i].ToString();

                if (char.IsLetterOrDigit(c, 0))
                {
                    appendBuilder.Append(c);
                }
                else if (c == "^" || c == ")" || c == "}")
                {
                    stack.Push(c);
                }
                else if (c == "(" || c == "{")
                {
                    while (stack.Peek() != null && stack.Peek() != ")" && stack.Peek() != "}")
                    {
                        appendBuilder.Append(stack.Pop());
                    }

                    stack.Pop();
                }
                else if (c == "]") //Tarama tersten yapıldığı için karşılaşılan ilk parantez ] olur.
                {
                    char join = stringBuilder[--i];
                    while (join != '[')
                    {
                        tempBuilder.Append(join); // Reverse işlemi gerçekleşeceğinden Insert yerine Append metodunu kullandım.
                        join = stringBuilder[--i];
                    }

                    appendBuilder.Append("[" + tempBuilder.ToString() + "]");
                    tempBuilder.Clear();
                }
                else
                {
                    if (CheckRank(c) > CheckRank(stack.Peek()))
                    {
                        stack.Push(c);
                    }
                    else
                    {
                        while (stack.Peek() != null && CheckRank(c) < CheckRank(stack.Peek()))
                        {
                            appendBuilder.Append(stack.Pop());
                        }
                        stack.Push(c);
                    }
                }
            }

            while (stack.Peek() != null)
            {
                appendBuilder.Append(stack.Pop());
            }

            return(Reverse(appendBuilder));//İfade ters çevrilerek işlem sonlandırılır.
        }