如何动态执行C#代码 [英] How to execute a c# code dynamically

查看:57
本文介绍了如何动态执行C#代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究C#3.5 winforms项目。

I am working on C# 3.5 winforms project.

我想动态执行一些代码,该代码位于字符串变量中。
代码,我要执行的代码是这样的:

I want to execute some code dynamically, which is in a string variable. the code, I want to execute is something like this :

(GetSetting("MYSETT1") == 1? "OK" : "Cancel")

我想使用项目中存在的方法,并且通过使用它们,我想执行一些任务。

I want to use methods which are existed in my project and by using them I want to perform some task.

可以动态地吗?

推荐答案

您可以动态地编译代码并执行。

You can dynamically compile your code and execute.

此链接可能会有所帮助:

This links may be helpful:

使用CodeDOM

在.Net中动态执行代码

这篇关于如何动态执行C#代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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