// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.CodeDom.Compiler; using Microsoft.JScript; namespace E { public static class JS { private static CodeDomProvider comp; private static CompilerParameters opt; static JS() { comp = new JScriptCodeProvider(); opt = new CompilerParameters(); opt.GenerateInMemory = true; opt.GenerateExecutable = true; } public static object Evaluate(string s) { return comp.CompileAssemblyFromSource(opt, "eval(" + s + ")").CompiledAssembly.EntryPoint.Invoke(null, new object[] { null } ); } } public class MainClass { public static void Main(string[] args) { object res = JS.Evaluate("(5 == 8) && (320 > 840) && (400.00 > 1000.00)"); Console.WriteLine(res==null); } } }