How to convert string to code in C #

I saw a question like this in C ++ I am very beginner and I need a very simple example how to do it. user writes code in textbox and I need him to execute like ???

+1


source to share


2 answers


You can use classes in the System.CodeDom namespace to compile C # into in-memory assemblies and run them on the fly. Here's a mini tutorial .



Alternatively, you can use Reflection.Emit to generate code on the fly.

+2


source


Check out the approach used in this.



+1


source







All Articles