Ok, my current problem is that in my switch statement(below) I am having trouble with "implicitly trying to convert one type to another". At first I made a initiated a char that I used like
Code:
char testChar = myStack.Pop();
switch(testChar)
{
/////
code
/////
}
(From which I got an error about implicitly Converting char to str).
Additionally, I tried to just make the pop statement equal to a string value.
After that I just simply switched off of the value popped of the stack. (As seen in the code below). This time the error that was
: A value of an integral type expected
Also, this is part of a program designed to convert infix to prefix or postfix notation and vice versa... maybe that will provide a little insight as to my intentions.......
Help please?
P.S. I am sure some of you have probably seen this before, I just cleaned it up a bit and made a thread exclusive to this particular problem...
while(myStack.Count != 0)
{
switch(myStack.Pop())
{
case "+":
if(operatorStack.Peek() == "*")
{
//lowerPrecedence = true;
strPostfix += operatorStack.Pop();
}
else if(operatorStack.Peek() == "/")
{
strPostfix += operatorStack.Pop();
}
else
operatorStack.Push(myStack.Pop());
break;
case "-":
if(operatorStack.Peek() == "*")
{
//lowerPrecedence = true;
strPostfix += operatorStack.Pop();
}
else if(operatorStack.Peek() == "/")
{
strPostfix += operatorStack.Pop();
}
else
operatorStack.Push(myStack.Pop());
break;
case "/":
//code
break;
case "*":
//code
break;
case "1":
strPostfix += myStack.Pop();
break;
case "2":
strPostfix += myStack.Pop();
break;
case "3":
strPostfix += myStack.Pop();
break;
case "4":
strPostfix += myStack.Pop();
break;
case "5":
strPostfix += myStack.Pop();
break;
case "6":
strPostfix += myStack.Pop();
break;
case "7":
strPostfix += myStack.Pop();
break;
case "8":
strPostfix += myStack.Pop();
break;
case "9":
strPostfix += myStack.Pop();
break;
case "0":
strPostfix += myStack.Pop();
break;
}
}