In the below code in the try statement we have a return statement, will the finally block still run.
public static void Main()
{
try
{
// Some code
return;
}
finally
{
//Will this run
}
}
Yes , the finally code will run even though there is a return statement in the try. Finally block will run irrespective what happens in try block. That’s the reason why finally block is a good place to put clean up code.
For more such c# and .NET interview questions and answers visitwww.questpond.com
This .NET interview question is taken from the book .NET interview questions and answers book by Shivprasad koirala.
