Yesterday, I posted an answer to a question on Code Project dealing with evaluating expressions in C#.  The person who asked the question wanted to know how to evaluate expressions with an eval() function (like the one in JavaScript/JScript).

After playing around with some code snippets, I came up with the following answer:

using System;
using Microsoft.JScript; //Microsoft.JScript.dll
using Microsoft.JScript.Vsa; //Microsoft.Vsa.dll

string expr = @"
  var x = 11;
  var y = 'A';
  var bEval = false
  if ((x > 10) && (y == 'A'))
    bEval = true;
    bEval = false;

VsaEngine engine = VsaEngine.CreateEngine();

object o = null;

  o = Eval.JScriptEvaluate(expr,engine);
catch(Exception e)

Console.WriteLine(o); //Outputs 'True' to the console

Enjoy the code!