Dynamic C# code execution
I need to run small snippets of C# code for educational purposes a开发者_运维技巧nd for each execution, I should open the project (solution), delete existing code, type new code, build and compile, and then run the project. For example, for executing string.IsNullOrEmpty("something")
I should follow all this procedure.
I just thought of something like:
In which I can enter code snippets, click execute, and then see the result. Is there anyway to do that?
You didn't explicitly state if you're looking for guidance on implementing your own solution or what, but if you're open to using a third party utility then LINQPad is pretty much exactly what you're describing.
Take a look at Snippet Compiler.
Not exactly what you're asking for, but from what I can tell it seems pretty close.
There is also ideone which can run C# code, as well as a large number of other languages.
There is also mono's csharp/gsharp:
see http://www.mono-project.com/CsharpRepl
Mono are doing the compiler as service stuff - this is what you are looking for: http://tirania.org/blog/archive/2010/Apr-27.html
精彩评论