{
public partial
class WebForm1 : System.Web.UI.Page
{
protected void
Page_Load(object sender,
EventArgs e)
{
}
protected void
Button1_Click(object sender,
EventArgs e)
{
if (string.IsNullOrEmpty(TextBox4.Text)
|| string.IsNullOrEmpty(TextBox1.Text))
{
Label5.Text =
"Please Enter Some Values";
Label5.ForeColor = System.Drawing.Color.Red;
}
else
{
ArithmticDelegate
objAdd = delegate(double
a, double b)
{
return a + b;
};
Label5.Text =
"Addition Result is: " + objAdd.Invoke(double.Parse(TextBox4.Text),
double.Parse(TextBox1.Text));
Label5.ForeColor = System.Drawing.Color.Green;TextBox1.Text
= string.Empty;TextBox4.Text =
string.Empty;
}
}
protected void
Button2_Click(object sender,
EventArgs e)
{
if (string.IsNullOrEmpty(TextBox4.Text)
|| string.IsNullOrEmpty(TextBox1.Text))
{
Label5.Text =
"Please Enter Some Values";Label5.ForeColor =
System.Drawing.Color.Red;
}
else
{
ArithmticDelegate objSub = delegate(double
a, double b)
{
return a - b;
};
Label5.Text =
"Substraction Result is: " + objSub.Invoke(double.Parse(TextBox4.Text),
double.Parse(TextBox1.Text));
Label5.ForeColor = System.Drawing.Color.Green;TextBox1.Text
= string.Empty;TextBox4.Text =
string.Empty;
}
}
protected void
Button3_Click(object sender,
EventArgs e)
{
if (string.IsNullOrEmpty(TextBox4.Text)
|| string.IsNullOrEmpty(TextBox1.Text))
{
Label5.Text =
"Please Enter Some Values";Label5.ForeColor =
System.Drawing.Color.Red;
}
else
{
ArithmticDelegate objMul = delegate(double
a, double b)
{
return a * b;
};
Label5.Text =
"Multiplication Result is: " + objMul.Invoke(double.Parse(TextBox4.Text),
double.Parse(TextBox1.Text));
Label5.ForeColor = System.Drawing.Color.Green;TextBox1.Text
= string.Empty;TextBox4.Text =
string.Empty;
}
}
protected void
Button4_Click(object sender,
EventArgs e)
{
if (string.IsNullOrEmpty(TextBox4.Text)
|| string.IsNullOrEmpty(TextBox1.Text))
{
Label5.Text =
"Please Enter Some Values";Label5.ForeColor =
System.Drawing.Color.Red;
}
else
{
ArithmticDelegate objDiv = delegate(double
a, double b)
{
return a / b;
};
Label5.Text =
"Division Result is: " + objDiv.Invoke(double.Parse(TextBox4.Text),
double.Parse(TextBox1.Text));
Label5.ForeColor = System.Drawing.Color.Green;TextBox1.Text
= string.Empty;TextBox4.Text =
string.Empty;
}
}