What is meant by connection.Dispose() in C#?
What is meant by connection.Dispose() in C#?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
A class implements IDisposable interface contains a method called
Dispose(), where you can release resources or do something else.Also, a
usingstatement can help to callDispose()method automatically.What happens when you call
myClass.Dispose()depends on what you wrote in theDisposemethod. For example:so if you want to know what happened when you call
connection.Dispose(), you must take a look at theDispose()method of the class of connection(maybe it’s a SqlConnection?). If it’s a .NET built-in library(which means you can’t get the source code easily), you can use a tool to help called Reflector