i would like to know if there is a way to conver a string + to a real plus. Example
string bla = "4+2";
i would like to reach, 4 + 2 = 6
Thanks!
i would like to know if there is a way to conver a string + to a real plus. Example
string bla = "4+2";
i would like to reach, 4 + 2 = 6
Thanks!
Try this
using System.Data; //refference for DataTable
string bla = "4+2";
object value = new DataTable().Compute(bla , null);
string res=value.ToString();//res=6
you can compile the expression and evaluate it at runtime. take a look here: http://www.codeproject.com/Articles/3988/Evaluating-Mathematical-Expressions-by-Compiling-C
Try Following Code
string bla = "4+2";
Expression exp = new Expression(bla);
Console.write(exp.Evaluate());
Int32 Number1;
Int32 Number2;
String Result = Convert.ToString(Number1+Number2);