J
Jeff B.
If an object implements the IDisposable interface, should I always call the
Dispose method or is just setting it to null and letting the GC handle it
sufficient? Here is the pattern I've been using but wasn't sure if it was
necessary:
DataAdapter da = null;
try {
// Some logic here...
} catch (Exception ex) {
// Some exception handling logic here...
} finally {
// Clean up...
if (da != null) {
da.Dispose();
da = null;
}
Is the above necessary or could I just set da = null in the "finally" clause
and be good?
--- Thanks, Jeff
--
Jeff Bramwell
Digerati Technologies, LLC
www.digeratitech.com
Manage Multiple Network Configurations with Select-a-Net
www.select-a-net.com
Dispose method or is just setting it to null and letting the GC handle it
sufficient? Here is the pattern I've been using but wasn't sure if it was
necessary:
DataAdapter da = null;
try {
// Some logic here...
} catch (Exception ex) {
// Some exception handling logic here...
} finally {
// Clean up...
if (da != null) {
da.Dispose();
da = null;
}
Is the above necessary or could I just set da = null in the "finally" clause
and be good?
--- Thanks, Jeff
--
Jeff Bramwell
Digerati Technologies, LLC
www.digeratitech.com
Manage Multiple Network Configurations with Select-a-Net
www.select-a-net.com