如何将字符串转换为代码在c#
问题描述:
我看到有在C + +
这样的问题我是一个非常初学者,我需要一个非常简单的例子,如何做到这一点。
用户在文本框中写代码,我需要什么o不要是执行它
如何???
I saw there is such question in c++ I am a very begginer and I need a very simple example how to do it . the user writes code in the text box and what I need o do is to execute it how???
答
您可以使用类中的System.CodeDom命名空间编译C#到内存组件,并在飞行运行它们。 这里是一个迷你型的教程。
You can use the classes in the System.CodeDom namespace to compile C# into in-memory assemblies, and run them on the fly. Here is a mini-tutorial.
另外,你可以使用 Reflection.Emit的来构建移动代码。
Alternatively, you can use Reflection.Emit to construct code on the fly.