Click to See Complete Forum and Search --> : Eval( ) in C#


NeoN/\K
September 6th, 2002, 04:05 AM
Hi all

I was wondering if it is possible or if there exists a piece of code
on how to eval a string like in javaScript or PHP.

Example:
> var $variable;
> eval( "$variable = \'hello\'"); // $variable now holds value hello
> echo $variable; // Output = Hello

Is this possible in C# ?

NeoNak

Arild Fines
September 6th, 2002, 06:02 AM
Not really, no. You can compile an assembly programmatically, but this isn't for the faint of heart. If you really need this kind of functionality, I suggest you write that part in JScript.NET and use the JScript class from C#.