Returning from finally



Can we return from finally block? If your answer is yes, take a look at this code.
We have a function body as ;

try
{  
   return "From try"; 
}
catch (Exception ex)
{ 
   return "From Catch"; 
}
finally
{
   return "From Finally"; 
}

If this is enclosed in a function and we are giving call to the function,
what will be the return value of this statement?
And the answer is, it will give a compilation error, as we cannot return from finally block.

No comments:

Post a Comment