执行在C#4.0中的字符串 [英] Execute a string in C# 4.0

查看:145
本文介绍了执行在C#4.0中的字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要执行在C#中动态创建的字符串。我知道VB和JScript.Net可以做到这一点,而且甚至有一个方式利用其装配在C#作为一种解决方法。我也发现了这个文章描述如何做到这一点。

I want to execute dynamically created string in C#. I know VB and JScript.Net can do it, and there is even a way to use its assembly in C# as a workaround. I also found this article describing how to do it.

我今天看了关于C#4.0的功能而使其更接近具有此为主要特征之一的动态语言。因此,没有任何人知道呢C#4.0包括一些内置的功能,允许执行字符串或任何其他方式做什么上面的文章中介绍。

I read today about C# 4.0 features which bring it closer to the dynamic languages that have this as one of the main features. So, does anybody know does C# 4.0 includes some built in features that allows for string execution, or any other way to do whats described in the article above.

推荐答案

有执行任意的C#源$ C ​​$比编译到组装,然后执行它的其他的C没有别的办法。安德斯·海尔斯伯格(C#的建筑师)宣布,计划以暴露C#编译器作为服务(主要是一组CLR类的),所以这可能是一些帮助,当发生这种情况。

There's no other way of executing arbitrary C# source code other than compiling it into assembly and then executing it. Anders Hejlsberg (architect of C#) announced plans to expose the C# compiler as a service (basically a set of CLR classes), so this might be of some help when this happens.

编译器即服务基本上意味着你可以编译code进入前pression任意一块,或者更​​好的,到AST和普遍得到内部编译器运作的搁置。

"Compiler as a Service" basically means that you can compile an arbitrary piece of code into Expression or, better yet, into an AST and generally get hold of internal compiler workings.

这篇关于执行在C#4.0中的字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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