We've seen many questions about try-catch-finally and try-finally constructions on this forum.
The number of answers increases the number of questions, so I have few too.
Here's a link into Microsoft explanation try-finally construction. I've already read it!
In the following article writes:
Within a handled exception, the associated finally block is guaranteed to be run. However, if the exception is unhandled, execution of the finally block is dependent on how the exception unwind operation is triggered. That, in turn, is dependent on how your computer is set up.
Am i correctly understand that in
try-catch-finallyconstructionfinallywill always be executed? (ExcludingEnvironment.FastFail())I've read about
StackOverFlowException(thatfinallyblock isn't executed in this occasion) on this forum, but when Ithrowit, thefinallyblock is executed. So What's aboutStackOverFlowException?Why
finallyblock is not called?(In the code below)?For which cases we generally use
try-finally?From what PC setting the
finallyblock is depended?
using System;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
try
{
throw new Exception();
}
finally
{
Console.WriteLine("finally");
Console.ReadKey();
}
}
}
}