So for this we can use compute method of Data Table class. lets assume you have a textbox with ID Textbox1 to enter the expression. Then a Calculate button and a result Textbox2 to show the result. So you can do this as follows. In your code behind file writeusing System.Data; //On button click you have to write these lines DataTable dt = new DataTable(); Textbox2.Text=dt.Compute(Textbox1.Text,"");By using just 3 lines of code you will have with you a working calculator which can evaluate any arithmetic expression.
Kapil is correct .You can make it in one line like textBox2.Text = new DataTable().Compute(textBox1.Text, "").ToString();