Monday, May 12, 2014

Console Output

Question: Write the output (what would be written to the console), when this following block of code is run:

 static void Main(string[] args)
        {
            try
            {
                Console.WriteLine("A");
                // Some Code Here
                Exception ex = new Exception("123456");
                throw (ex);
                Console.WriteLine("B");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
            finally
            {
                Console.WriteLine("Done");
                Console.ReadLine();
            }
        }
        
Answer:
A
System.Exception: 123456
Done

No comments:

Post a Comment