Developer technologies | C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
static int DivInt(int A, int B)
{
return A / B:
}
private static void ExceptionH()
{
Console.WriteLine(DivInt(10,2))
};
you mean??????????
static int DivInt(int A, int B)
{
if(B == 0)
{
throw new ArgumentException("Cannot divide by zero");
}
return A / B;
}
private static void ExceptionH()
{
try
{
Console.WriteLine(DivInt(10, 0));
}
catch (ArgumentException ex)
{
Console.WriteLine("Error: " + ex.Message);
}
}