.net 4 - run code from string - in C# / F# / IronRuby / IronPython
问题 What ways do I have in .net to run code from string? Console.WriteLine(Compile("1 + 2 * 3")); // results is 7. What other options do we have? C# - Compile the code on runtime? IronRuby / IronPython? F#? 回答1: So, the dynamic languages like IronRuby and IronPython make it very easy to do what you want. Create a script engine and execute the string. Easy as that. C#, it is possible, using the Code DOM... but it it compiles the code every time into a DLL. This is a costly behavior and can cause