Hi friends ,
I have a string like : "10*2"
now, i want to return the result as a float for that string expression : 20 = (10*2)
how can i do it , thanks .
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
MinhPosted Jul 19, 2010, 3:00 AM
For example : you have a string : x= " (2*3+2*(2-8))"
and what you do is : y=&x (=-6 as the result from x) .
But i do not know what I should do in c#.net , it is very difficult .
MinhPosted Jul 14, 2010, 4:05 AM
I have a complex string with equators like +,-,*,/ and others like "(",")" in an expression .
For example : (10*2)+((8*6-9*5+3*2)*(72*7/2)) .
Hope for your help soon . it is urgent for me . Thanks much. ( Sorry if i give the very simple in the original question )
Syed ShakeerPosted Jul 14, 2010, 3:45 AM
String str="10*2";
string [] spl=str.Split(*);
float a=Convert.ToFloat(spl[0]);
float b=Convert.ToFloat(spl[1]);
float result=a * b;