Forum Moderators: open
I'm trying to evaluate string formulas. I tried something like this:
arithmetic = "2 + 4 * 95 - 6"
eqResult = eval(arithmetic)
but it didn't work. I got an error that "eval" is undeclared.
Does asp.net support the evaluation of strings in the first place? I know Javascript and ColdFusion do...
Thanks,
NB
[odetocode.com...]
but I think you was looking for something a little easier than that. I have been using ASP.NET for a while now and I haven't ran into something to the equivalent of eval();
Really, .NET code behind was meant to have the DataTypes that they have now. They were meant to be used accordingly. By the time you convert your elements to Integers....using Convert.ToInt32(string) it would be probably just as fast by the time it decided to do all the parsing for eval(). Plus when you convert them...you KNOW that they are of this DataType and everything is consistant in your code....and very straight forward. Although this is a different concept for some peeps but that is just me. Hope that helps.