Having read the threads Is SqlCommand.Dispose enough? and Closing and Disposing a WCF Service I am wondering for classes such as SqlConnection or one of the several classes inheriting from the Stream class does it matter if I close Dispose rather than Close?
Having read the threads Is SqlCommand.Dispose enough? and Closing and Disposing a WCF Service
Share
I want to clarify this situation.
According to Microsoft guidelines, it’s a good practice to provide
Closemethod where suitable. Here is a citation from Framework design guidelinesIn most of cases
CloseandDisposemethods are equivalent. The main difference betweenCloseandDisposein the case ofSqlConnectionObjectis:That said:
Dispose. Ausingblock will ensure this is called even in the event of an exception.Closemethod.