I don\'t have a problem; I\'m just curious. Imagine the following scenario:
foreach (var foo in list)
{
try
{
//Some code
}
catch (E
You may think it makes sense, but it doesn't make sense actually.
foreach (var v in List)
{
try
{
//Some code
}
catch (Exception)
{
//Some more code
break; or return;
}
finally
{
continue;
}
}
What do you intend to do a break or a continue when an exception is thrown? The C# compiler team doesn't want to make decision on their own by assuming break
or continue
. Instead, they decided to complain the developer situation will be ambiguous to transfer control from finally block
.
So it is the job of developer to clearly state what he intends to do rather than compiler assuming something else.
I hope you understand why this doesn't compile!