I wanted to know if there was any equivalent of the eval function that
javascript has. basically if i can construct a statement in a string and
then evaluate it.
thanks!
http://www.codeproject.com/csharp/runtime_eval.asp
They have a math expression parser in the info.lundin.Math namespace.
J
"RP" <r...@nospam.com> wrote in message
news:u6fEHJqC...@TK2MSFTNGP10.phx.gbl...
Since the .NET framework has a JScript.NET compiler, you can do the
following...
1) copy the following to a .js file (for example myeval.js):
// =============================
package JSUtil {
class Util {
static public function Eval( s : String) {
return( eval( s));
}
}
}
// =============================
2) compile it at the command line using "jsc /t:library myeval.js"
3) in your VB.NET or C# (or whatever .NET language), reference the following
assemblies:
myeval.dll - (the library built above)
Microsoft.JScript - (the JScript.NET runtime)
4) call JSUtil.Util.Eval() when you want to evaluate a string. For example:
Console.WriteLine( "2+6")
will print "8" on the console.
--
MikeB