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,010
  • 13
  • 100
  • 141
stighy
  • 7,595
  • 22
  • 89
  • 150
  • 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,439
  • 15
  • 91
  • 140
0

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

Enes
  • 3,911
  • 3
  • 24
  • 23