private void Eval() { Stack<double> values = new Stack<double>(); PostfixValue value; while (_postfix.Count > 0) { value = _postfix.Dequeue(); if (value.IsNumeric()) { values.Push(value.Value()); } else { switch (value.Operator()) { case '+': values.AddInPlace(); break; case '-': values.SubtractInPlace(); break; case '/': values.DivideInPlace(); break; case '*': values.MultiplyInPlace(); break; case '^': values.PowInPlace(); break; } } } if (values.Count > 1) throw new ArgumentException("Too many values"); _postfix.Enqueue(new PostfixValue(values.Pop())); }