I wrote the following test code, even though I was pretty sure what would happen:
static void Main(string[] args)
{
Console.WriteLine(Test().ToString());
Console.ReadKey(false);
}
static bool Test()
{
try
{
try
{
return true;
}
finally
{
throw new Exception();
}
}
catch (Exception)
{
return false;
}
}
Sure enough, the program wrote "False" to the console. My question is, what happens to the true that is originally returned? Is there any way to get this value, in the catch block if possible, or in the original finally block if not?
Just to clarify, this is only for educational purposes. I would never make such a convoluted exception system in an actual program.