Jonas,
You have at least three alternatives to proceed:
A) Create your own parser to parse the expressions to some intermediate
representation and then compile and execute (or interpret) that. (keywords
for google, recursive descent parser, abstract stack machine).
B) If the expressions are valid C# (VB) you could utilize the inbuild
features of .NET. Create CodeDom compile unit from the expression, compile
it to assembly and execute that. (namespaces to study System,
System.CodeDom, System.CodeDom.Compiler, System.Reflection).
C) Incorporate scripting capabilities to your application via VSA (Visual
Studio for Applications). (namespace to study Microsoft.Vsa and newsgroup
....dotnet.vsa).
You might wanna specify more detailed manner your requirements inorder to
have better advice which route to take.
Ron
"Jonas Prismesen" <pr*******@hotmail.com> wrote in message
news:0b****************************@phx.gbl...
Hi!
I have string like this:
string expr = "123/(12*3)";
And I want to actually calculate the mathematical
expression in the string. Is there an easy way do it? Or
do I have to extract all the parts from the string, which
will be difficult since the expression will change in my
app..
I'm using VS.NET 2003 and c#.
In advance thank you!