----------------------------------------------------------- New Message on BDOTNET
----------------------------------------------------------- From: shri Message 3 in Discussion Hi, Let me attempt to explain all of them: Difference between dispose and finalize: As you know VB.net object are garbage collected unlike in VB where you can be sure that the terminate event will run immediatley after the object's referece count becomes zero. Thus, you can place all resource cleanup code in a Finalize method. Note that at runtime this may be called when garbage collector gets around to destroying these objects. In VB.net there is a work around to this.Microsoft actually recommends using "Dispose" method for this. Class CResourcewrapper Public Sub dispose() ' call dispose on any contained managed resources ' free the unmanaged resources ' suprress finalization GC.SuppressFinalize(Me) End Sub Protected overrides Sub finalize() ' do not call dispose any contained managed resources ' free the unmanaged resources ' call base class finalize method MyBase.Finalize() End Sub End Class Difference between close and dispose method (Related to ADO.NET) Sometimes developers use this (which is also recommended) connection.Close(); connection.Dispose(); The Dispose() method for SqlConnection however closes the connection and also does some extra cleanup because it checks the ConnectionState... if it's closed, it sets itself to null, if its open, it calls the Close() method. After that it calls System.ComponentModel.Component.Dispose(). Note: For readability purpose it is always better to use both the methods Also note that there is a huge difference between Close() and Dispose() Methods. The latter really kills the connection from the pooling connection. Remember that Pooling is True by Default in the connection String. If you change it to false, dispose is unnecessary. You can confirm this using SQL Profiler. Difference between throw and throw ex Error handling: Please check the link below: http://www.dotnetspider.com/Technology/Tutorials/ExceptionHandling.aspx Wooof wooof.... (So many queries in one message.....difficult to answer. Break them into smaller ones.) Hope I have answered your doubts, Regards, shri ----------------------------------------------------------- To stop getting this e-mail, or change how often it arrives, go to your E-mail Settings. http://groups.msn.com/bdotnet/_emailsettings.msnw Need help? If you've forgotten your password, please go to Passport Member Services. http://groups.msn.com/_passportredir.msnw?ppmprop=help For other questions or feedback, go to our Contact Us page. http://groups.msn.com/contact If you do not want to receive future e-mail from this MSN group, or if you received this message by mistake, please click the "Remove" link below. On the pre-addressed e-mail message that opens, simply click "Send". Your e-mail address will be deleted from this group's mailing list. mailto:[EMAIL PROTECTED]
