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
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 |
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 |
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 |
Answer / kranthi
Yes..irrespecitve of writing goto or return or exception
occured, finally block will execute.
| Is This Answer Correct ? | 1 Yes | 0 No |
Is unity object oriented?
Compare and contrast between the System.Array.CopyTo() and Clone()?
Can constructor be overloaded in c#?
Can private virtual methods be overridden in c#.net?
Can we have static indexer in c#?
Why is ienumerable used?
What is difference between constants and read-only?
When do you absolutely have to declare a class as abstract (as opposed to free-willed educated choice or decision based on UML diagram)?
If a child class instance is created, which class constructor is called first - base class or child class?
What is difference between for and foreach in c#?
How?s method overriding different from overloading?
What is difference between list and dictionary in c#?
Visual Basic (800)
C Sharp (3816)
ASP.NET (3180)
VB.NET (461)
COM+ (79)
ADO.NET (717)
IIS (369)
MTS (11)
Crystal Reports (81)
BizTalk (89)
Dot Net (2435)
Exchange Server (362)
SharePoint (720)
WCF (340)
MS Office Microsoft (6963)
LINQ Language-Integrated Query (317)
WPF (371)
TypeScript (144)
Microsoft Related AllOther (311)