Quiz: More Exception Mysteries
Yesterday I heard about a cool Whidbey feature that inspired me to come up with this little quiz. The code below when run will print out:
In try
In catch
After try..catch
class Program
{
static void Main(string[] args)
{
try
{
Console.WriteLine("In try");
throw new Exception();
}
catch (Exception)
{
Console.WriteLine("In catch");
}
Console.WriteLine("After try..catch");
}
}
By only adding a few lines of code above the try-statement in the Main() method have it printed out:
In try
Mystery inserted code
In catch
After try..catch
There are no funky streaming, buffer magic required. Also, you can’t add any code below the try-statement nor can you add any other types, methods, etc to the program. I will give you one hint, you will need the Whidbey pre-release for this one..