public static class CheckYourNumber
{
public static ApplicationException EvenOrOdd(int integer)
{
if (integer % 2 == 0)
{
return new ApplicationException(“The integer is even.”);
}
else
{
return new ApplicationException(“The integer is odd.”);
}
}
}
protected void Button_Click(object sender, EventArgs e)
{
try
{
throw CheckYourNumber.EvenOrOdd(Convert.ToInt32(txtIntToTest.Text));
}
catch (ApplicationException ex)
{
lblResult.Text = ex.Message;
}
}
I loved it :)
No comments:
Post a Comment