Convert string to executable code at run time in c#?

微笑、不失礼 提交于 2019-11-30 16:21:06

You can use CSharpCodeProvider class, but you'll need to build quite a bit of extra code around the snippet, as you have to provide a full class. I did this for my "Snippy" tool for C# in Depth, and you can download the source to get one simple example of how it can be done.

However, life is becoming much simpler in this area with Roslyn - you may want to get hold of the CTP and explore that.

Have a look at the Roslyn ScriptEngine.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!