class MyEval{ function execute(code:String) :String { // Method. return eval(code); } }
2.编译成dll
jsc /target:library /out:MyEval.dll MyEval.js
3.编写测试文件 TestEval.cs
using System; class test{ public static void Main(){ string code = "var result:int =0;result==1?\"成功\":\"失败\""; MyEval eval = new MyEval(); string result = eval.execute(code); Console.WriteLine("The Result is:" + result); } }