F
Frank Lund
Should we call .Dispose() every chance we get... on every object that
exposes .Dispose()... and every time we have such an object?
For example, is it true that *every* time I create a DataTable and use it,
that I should call .Dispose of the DataTable instance when I'm done with it?
I was told this is a good .NET programming practice. But I also thought that
..Dispose was there for us to use to clean up objects that actually need
cleaning up - like if we have an object that holds a file handle or database
connection... in that case we'd certainly implement Dispose and cut
connections etc in it. But what about DataTable and other "similar"
..NET-provided objects that apparently don't really hold references to files,
databases, and the like? Is there a good reason to call Dispose on those
objects anyway?
Thanks.
exposes .Dispose()... and every time we have such an object?
For example, is it true that *every* time I create a DataTable and use it,
that I should call .Dispose of the DataTable instance when I'm done with it?
I was told this is a good .NET programming practice. But I also thought that
..Dispose was there for us to use to clean up objects that actually need
cleaning up - like if we have an object that holds a file handle or database
connection... in that case we'd certainly implement Dispose and cut
connections etc in it. But what about DataTable and other "similar"
..NET-provided objects that apparently don't really hold references to files,
databases, and the like? Is there a good reason to call Dispose on those
objects anyway?
Thanks.