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
Is comparator a functional interface?
What is expression tree in c#?
How more than one version of an assembly can keep in same place?
explain the three services model commonly know as a three-tier application.
What is static noise?
How can I produce an assembly?
How do I declare a pure virtual function in c#?
In how many ways you can overload a method?
Why is it not a good idea to use empty destructors?
What is a Command Object in C#?
Can you specify nested classes as partial classes?
In .Net, what is an assembly? Also explain the type of assembly.
What is msil, and why should developers need an appreciation of it if at all?
What is the difference between static and private constructor in c#?
What is difference between struct and class in c#?