c# - How to Dispose an object using Dispose method -
this question has answer here:
- proper use of idisposable interface 18 answers
how dispose managed or unmanaged objects using dispose method?
in application class implemented idisposable interface , gave overridden method dispose(). actual doubt how dispose managed or unmanaged code in dispose method.
public override void dispose() { // should unmanaged objects? // can make object set 'null'? }
the dispose method works using
statement. automatically called if using
block closed.
class : idisposable { public void dispose() { // dispose } } using (a = new a()) { }
you don't need override
method, because defined in interface.
in case using
leaved, dispose called.
Comments
Post a Comment