Should I implement IDisposable here?
Posted
by dotnetdev
on Stack Overflow
See other posts from Stack Overflow
or by dotnetdev
Published on 2010-05-19T16:53:58Z
Indexed on
2010/05/19
17:00 UTC
Read the original article
Hit count: 130
c#
My method which calls SQL Server returns a datareader but because of what I need to do (return the datareader to the calling method which is in page code-behind), I can't close the connection in the class of the method which calls sql server, so I have no finally or using blocks.
Is the correct way of disposing resources to make the class implement IDisposable? Or from the caller, explicitly dispose the unmanged resource (class-level fields)?
Thanks
© Stack Overflow or respective owner