.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Interview Question >> C# >> Post New Question Subscribe to Interview Questions

Can we have return statement in Final block?

Posted By :Narayanan     Posted Date :November 22, 2011    Points :40   Category :C# 
No,Final block is being run as a effect of exception thrown from try block.

You can also find related Interview Question to Can we have return statement in Final block?  below: 

what is Purpose of using Return Statement?

  
returns flow of control from a method to the caller,optionally,passing by a return value. (More...)

what is Purpose of using Return Statement?

  
returns flow of control from a method to the caller,optionally,passing by a return value. (More...)

What is the use of return statement

  
The return statement is associated with procedures (methods or functions). On executing the return statement, the system passes the control from the called procedure to the calling procedure. This return statement is used for two purposes :

to return immediately to the caller of the currently executed code

to return some value to the caller of the currently executed code. (More...)

Can code inside multiple catch block be executed?

  
No, Code can not execute in mutiple catch block (More...)

What is return type of Executenonquery() ?

  
int will be returned when you call ExecuteNonQuery() in ADO.NET (More...)

How many Columns per INSERT statement is allowed

  
4096 Columns allowed in per Insert SQL (More...)

Can multiple catch blocks be executed for a single try statement?

  
No. Once the proper catch block processed, control is transferred to the finally block (if any).

So we can not execute multiple catch block in one try block (More...)

How to deal with return value of stored procedure when you are using DataReader ?

  
To deal with such scenario, you can find "ParameterDirection.ReturnValue" in .net
You can use this parameter direction to read the return value of the stored procedure.

Following example can make it more clearer.
In case, you have following or similar type of return statement somewhere in your stored procedure.
Return -999
To read this value, following code works,

Dim result As Integer = 0
Dim retValParam As New SqlClient.SqlParameter("@RETURN_VALUE", SqlDbType.Int)
retValParam.Direction = ParameterDirection.ReturnValue
dbCommand.Parameters.Add(retValParam)
database.ExecuteNonQuery(dbCommand)
result = retValParam.Value ' here the result must contain the returned value. In this case, it will be -999 (More...)

Why do I get an error (CS1006) when trying to declare a method without specifying a return type?

  
If you leave off the return type on a method declaration, the compiler thinks you are trying to declare a constructor. So if you are trying to declare a method that returns nothing, use void. The following is an example: // This results in a CS1006 error public static staticMethod (mainStatic obj) // This will work as wanted public static void staticMethod (mainStatic obj) (More...)

What is the equivalent statement for exit in C#?

  
Application.Exit() or System.Environment.Exit (More...)

Quick Links For Interview Questions Categories:
ASP.Net Windows Application   .NET Framework   C#   VB.Net   ADO.Net  
Sql Server   SharePoint   Silverlight   OOPs   JQuery   JavaScript/VBScript
Biztalk Patten/Practices .IIS WCF WPF WWF
Networking Aptitude Others   All      

Find questions, FAQ's and their answers related to .NET, C#, Vb.Net, Sql Server and many more.

 
Now you can find lots of .NET, C#, Vb.Net, SQL Server,Windows, ASP.Net related Questions and their Answers here at www.dotnetspark.com. Our aim is to help you pass your certification Exams (MCP, MCSD, MCAD etc.,) with flying scores and get good name in your company.

So, Start looking our Interview Question section daily and improve your .NET Skills. You can also help others by posting Interview Questions and their Answers in this section.


Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend