如何将字符串转换为代码在c# [英] how to convert string to code in c#

查看:145
本文介绍了如何将字符串转换为代码在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.

这篇关于如何将字符串转换为代码在c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆