Đặng Thu Hà
New member
What will be the output of the following C# code?
A. This will generate an exception
B. 0
C. Compile time error
D.
This will generate an exception
Attempted to Divide by Zero
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();
}
B. 0
C. Compile time error
D.
This will generate an exception
Attempted to Divide by Zero