splitting operand and operator RRS feed

  • Question

  • hi I have a question, actually I want to get a Boolean expression as a input and I want to split it by two variable

    like temp1 will have all the operands, and temp2 will have all operators, and I want to do the process based on the operators count. here I attached my small piece of code

    string str = "A*B+C+D";string tmp1=string.Empty;string tmp2=string.Empty;
                for (int i = 0; i < str.Length; i++)
                    if (!isOperators(str[i]))



    when I tried to store string[I] in tmp1 its showing error.

    could anyone help me to cure this.

    whereas isOperators is a function which identify the operands.

    static bool isOperators(char c)
                return (!(c >= 'a' && c <= 'z') &&
                        !(c >= '0' && c <= '9') &&
                        !(c >= 'A' && c <= 'Z'));

    even I tried this using queue concept.

    Thursday, March 14, 2019 7:00 AM