using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication14
{
class Program
{
static void Main(string[] args)
{
int z = Add(“0”, “0”);
Console.WriteLine(z);

}

static int Add (string a, string b)
{

int x = 0;
int y = 0;
bool hasError = false;
try
{
x = Convert.ToInt32(a);
y = int.Parse(b);

}
catch (OverflowException ofe)
{

Console.WriteLine(ofe.Message );
hasError = true;
}
catch (ArgumentNullException ane)
{
Console.WriteLine(ane.Message);
hasError = true;
}
catch (FormatException fe){
Console.WriteLine(fe.Message);
hasError = true;
}
finally
{
if (hasError )
{
Console.WriteLine(“error”);
}
else
{
Console.WriteLine(“done”);
}
}

return checked(x + y);

}
}

}

Advertisements