stighy
stighy

Reputation: 7170

Execute .NET code at runtime

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 ?

Upvotes: 0

Views: 167

Answers (2)

Enes
Enes

Reputation: 3961

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

Upvotes: 0

IAbstract
IAbstract

Reputation: 19881

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.

Upvotes: 2

Related Questions