0

Suppose i write 'piece of code' in a text file. Is it possible to read that file at runtime and...execute ? For example, suppose my software have a method1, method2 and method3 methods. In a text file i write any simple piece of code, like:

dim i as integer
i = method1() + method2()
console.write(i)

How can execute it dinamically, at runtime ?

Charles
  • 50,943
  • 13
  • 104
  • 142
stighy
  • 7,260
  • 25
  • 97
  • 157
  • 1
    possible duplicate of [Is it possible to dynamically compile and execute C# code fragments?](http://stackoverflow.com/questions/826398/is-it-possible-to-dynamically-compile-and-execute-c-code-fragments) – Jon Sep 21 '11 at 15:36

2 Answers2

2

CodeDOMProvider and the System.CodeDom.Compiler Namespace is where you will want to start. But you will have to write more extensive code than your sample.

IAbstract
  • 19,551
  • 15
  • 98
  • 146
0

There is an example on MSDN for both VB and C#

Enes
  • 3,951
  • 3
  • 25
  • 23