title: Convert a string to an operator?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/355062/is-there-a-string-math-evaluator-in-net">Is there a string math evaluator in .NET?</a>  </p>
  </blockquote>
  
  
  
  <p>Is there a way to convert the operator code without doing a check for <code>"+", "-", "*", "/"</code> and then passing the value? </p>
  
  <pre><code>using System;
  
  namespace ConsoleApplication1
  {
      class Program
      {
          private static void Main(string[] args)
          {
              string operator = "+";
              int inputOne = 2;
              int inputTwo = 5;
  
              Console.WriteLine(Result(inputOne, inputTwo, operator));
              Console.ReadLine();
          }
  
  
          public static string Result(int one, int two, string computeOperator)
          {
              if (computeOperator == "+")
              {
                  return (one + two).ToString();
              }
  
              if (computeOperator == "-")
              {
                  return (one - two).ToString();
              }
  
              //and so on...
  
              return "0";
          }
      }
  }
  </code></pre>