解决方案 »

  1.   

    http://hi.baidu.com/odqljxdnckbenuq/item/29eb6b00742f61d8dce5b077
    可以研究用Microsoft.JScript;来做
      

  2.   


    public int FindParamer(string strParamer)
            {
                CSharpCodeProvider provider = new CSharpCodeProvider();
                CompilerParameters parameter = new CompilerParameters();
                parameter.ReferencedAssemblies.Add("System.dll");
                parameter.GenerateExecutable = false;
                parameter.GenerateInMemory = true;
                CompilerResults result =
                    provider.CompileAssemblyFromSource
                    (
                        parameter,
                        "using System;" +
                        "namespace calculate" +
                        "{" +
                            "public static class calculation" +
                            "{" +
                            "public static int calculateExpression()" +
                            "{" +
                                "return " + strParamer +
                            ";}}}"
                    );
                return Convert.ToInt32(result.CompiledAssembly.GetType("calculate.calculation").GetMethod("calculateExpression").Invoke(null,new object[]{}));
            }
      

  3.   

    上次找过一个,现在懒得找了    试试google eval + .net吧另外,可以用dynamic,查查.net的脚本语言吧