Answer: Yes, we can use the goto statement in the finally block.
Code snippet:
class abc
{
static void Main()
{
try
{
Console.WriteLine("welcome");
}
finally
{
goto dd;
dd:
Console.WriteLine("last");
}
}
}
//This block of code will execute since the label dd is inside the finally block.
//if the label dd was outside the finally block, the compiler would have generate
//the error--
cannot leave the body of finally clause
|
Alert Moderator