Is it possible to dynamically compile and execute C# code fragments?

I was wondering if it is possible to save C# code fragments to a text file (or any input stream), and then execute those dynamically? Assuming what is provided to me would compile fine within any Main() block, is it possible to compile and/or execute this code? I would prefer to compile it for performance reasons.

At the very least, I could define an interface that they would be required to implement, then they would provide a code ‘section’ that implemented that interface.

7 Answers
7

Leave a Comment