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 is data binding with example?
What is the difference between “dispose” and “finalize” variables in c#?
Explain the difference between “as” and “is” operators used in c#?
How many bytes is an int c#?
What is int32?
What is concrete class in c#?
What are the Types of values mode can hold session state in web.config
Why singleton pattern is used in c#?
Is it true that all c# types derive from a common base class?
Explain About Web.config
What is difference between singleton and static class in c#?
What is the correct way of declaring an xml namespace?
Define satellite Assembly in .NET?
What does addressof operator do in background ?
Which one is trusted and which one is untrusted?