How to execute a string’s instructions

Asked

Viewed 40 times

0

I have a string:

string str="for(int x = 0; x < 10; x++) Console.Write(\"hello\");"

How do I execute the instructions for this string?

for(int x = 0; x < 10; x++) Console.Write("hello");
  • This question has already been answered here and here I would suggest that you look at dynamiclinq source code on github which has there several examples where they compile and execute code next using Dynamic Expressions. here is an example

  • I put the using System.CodeDom; and the using System.CodeDom.Compile and yet the code is still missing references, it uses some other reference? I’m using . net 3.1 I think.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.