In this we will create simple calculator that
is able to add, subtract, multiply, and divide values.
Add following controls to your page, set their ID and other properties as in the
following table and arrange the control as shown in figure 1.2
Table

figure 1.2

Double click the Calculate button and add the following code to click event of button.
protected void Button1_Click(object sender, EventArgs e)
{
if (TextBox1.Text.Length > 0 && TextBox2.Text.Length > 0)
{
double res = 0;
double value1 = Convert.ToDouble(TextBox1.Text);
double value2 = Convert.ToDouble(TextBox2.Text);
switch (OperatorList.SelectedValue)
{
case "+":
Join the conversation! Your thoughts help the community grow.