?
What will be the output of the following C# code?
What will be the output of the following C# code?
static void Main(string[] args)
{
int a = 10, b = 0;
int result;
Console.Out.WriteLine("This will generate an exception.");
try
{
result = a / b; // generate an exception
}
catch (DivideByZeroException exc)
{
Console.Error.WriteLine(exc.Message);
}
Console.ReadLine();
}
static void Main(string[] args)
{
int a = 10, b = 0;
int result;
Console.Out.WriteLine("This will generate an exception.");
try
{
result = a / b; // generate an exception
}
catch (DivideByZeroException exc)
{
Console.Error.WriteLine(exc.Message);
}
Console.ReadLine();
}
Join the Discussion
Login to post a comment or share your explanation.
Login