If we write a goto or a return statement in try and catch
block will the finally block execute?
Answer Posted / uday
The statements after goto in try block wont be executed.
And Finally block also get executed.
static void Main(string[] args)
{
int a, b,c;
a = 10;
b = 0;
try
{
goto A;
c = a + b;
Console.WriteLine(c);
}
catch (Exception e)
{
Console.WriteLine("In parent exception Catch" +
e.Message);
}
finally
{
Console.WriteLine("In finally block");
}
A:
Console.WriteLine("at goto label");
Console.Read();
}
The output is:
In finally block
at goto label
| Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
What's the c# syntax to catch any possible exception?
What is dictionary collection in c#?
How do you escape a character?
How can I access the registry from c# code?
What is window application in c#?
Why delegates are type safe in c#?
What does it mean?
How does foreach loop work in c#?
Explain the difference between Response.Write () and Response.Output.Write ().
Why main method is static in c#?
What is gridview c#?
What Is The Difference Between The System.array.copyto() And System.array.clone()?
How long can a string be c#?
What is verbatim string?
Is a char?