If we write a goto or a return statement in try and catch
block will the finally block execute?

Answers were Sorted based on User's Feedback



If we write a goto or a return statement in try and catch block will the finally block execute?..

Answer / hhh

yes

Is This Answer Correct ?    15 Yes 3 No

If we write a goto or a return statement in try and catch block will the finally block execute?..

Answer / om namo bagavathe vasudevaya n

what ever goto or continue statement you used in try/catch
the finally bolck must be executed

even an exception occuerd or an exception not occured in the
try block the finally block defanetly executed

but they are some excptions like system exceptions and
application exceptions.For this exceptions the finally block
may or may not excute because

SYSTEM EXCEPTIONS:this excptions occur during runtime
examples:some hardware problems

Application Exception:they also probally occur whill the
application is running

example:if we give textbox maximum size limt as 50
characters.If we enter morethan 50 characters then some
exceptions should occur

Is This Answer Correct ?    13 Yes 2 No

If we write a goto or a return statement in try and catch block will the finally block execute?..

Answer / guest

yes, whatever may be the content of the try-catch blocks,
the finally block is going to execute

Is This Answer Correct ?    11 Yes 2 No

If we write a goto or a return statement in try and catch block will the finally block execute?..

Answer / 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

If we write a goto or a return statement in try and catch block will the finally block execute?..

Answer / kanan

Yes.

Is This Answer Correct ?    1 Yes 0 No

If we write a goto or a return statement in try and catch block will the finally block execute?..

Answer / kranthi

Yes..irrespecitve of writing goto or return or exception
occured, finally block will execute.

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More C Sharp Interview Questions

What is difference between il and dll ?

0 Answers  


f i give input like 1,1,4,5,6,1,2,5,4,1,2, then output should be like : 1-4, 2-2, 4-2, 5-1, 6-1 which means 1 occurs 4 times, 2 occurs 2 times like so.

7 Answers  


Can we overload indexer in c#?

0 Answers  


Why multiple Inheritence is not used in C#?

8 Answers   Symphony,


If you define a user defined data type by using the class keyword, is it a value type or reference type?

0 Answers  


Can an exception be thrown from a catch block?

0 Answers   Alcatel-Lucent,


What do you use c# for?

0 Answers  


Does google use c#?

0 Answers  


Can we create extension method for interface?

0 Answers  


What is ienumerable t in c#?

0 Answers  


What is a nullreferenceexception?

0 Answers  


What is the diff between the System.Array.CopyTo() and System.Array.Clone()?

0 Answers   Siebel,


Categories