[Mono-list] eval statement
Piers Haken
piersh@friskit.com
Wed, 21 Jan 2004 12:45:59 -0800
For simple expressions you can use XPath:
XPathNavigator nav = new XmlDocument ().CreateNavigator ();
Console.WriteLine (nav.Evaluate ("(7-1) div 2").ToString ());
Beyond that, you'll either need to write your own expression evaluator, or
build/load dynamic assemblies.
Here's a couple of articles:
http://codeproject.com/vb/net/math_expression_evaluator.asp
http://codeproject.com/dotnet/evaluator.asp
Piers.
> -----Original Message-----
> From: mono-list-admin@lists.ximian.com
> [mailto:mono-list-admin@lists.ximian.com] On Behalf Of Gonia
> Eric - egonia
> Sent: Wednesday, January 21, 2004 9:41 AM
> To: 'mono-list@ximian.com'
> Subject: [Mono-list] eval statement
>
> Does anyone have a recommendation on how I can create an eval
> method similar to perl's or php's.
>
> I would like to take a string like "(7-1)/2" and pass it to a
> method that would return the value of the mathematical operation.
>
> Thanks for any help you can provide,
> Eric
>