Examveda

What will be the output of the following C# code snippet?
class program
{
    public static void Main(string[] args)
    {
        try 
        {
            int a = args.Length;
            int b = 1 / a;
            Console.WriteLine(a);
        }
        catch (ArithmeticException e) 
        {
            Console.WriteLine("1");
        }
        Console.ReadLine();
    }
}

B. 1

C. Compile time error

D. Runtime error

Answer: Option B


Join The Discussion

Related Questions on Exception Handling in C Sharp