Is there any API for WP7 to get an arithmetic expression in a string and eval it?
Searched for it on google, but nothing comes up..
Thanks in advance.
Is there any API for WP7 to get an arithmetic expression in a string and eval it?
Searched for it on google, but nothing comes up..
Thanks in advance.
Searching for "C# parse arithmetic from string" I found a good bunch of resources, with this one the most appealing to me. I haven't tried, but I suppose it will compile on WP7.
Anyways, there's always the possibility of building your own parser. You can approach this using expression trees: read about this in this article (scroll down to the section Expression Trees) (in Java, but explains the concept pretty well and the language is similar enough to C# to be comprehensible).
You can also use the Shunting Yard algorithm, which uses a stack to evaluate the expression. These are only two approachs I remember now, I'm sure there are a lot more. It's harder than using third party libraries, but you can adapt them to your own requeriments.