How can you clean up objects holding resources from within
the code?

Answer Posted / nagasaichand

The recommended practice is to implement both Finalize as
well as Dispose methods on an object which needs to clean up
unmanaged resources. The Finalize method would serve as a
backup mechanism in the event that the Dispose is never
called. The garbage collector would perform the object
finalization and prevent a permanent leak of the unmanaged
resource.

Is This Answer Correct ?    4 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is windows application in c#?

481


What is gac? What are the steps to create an assembly and add it to the gac?

494


Illustrate race condition?

490


How do I simulate optional parameters to com calls?

516


What is difference between an Structure and Class?

575






What is marshalling and what are different kinds of marshalling?

513


So let's say I have an application that uses myapp.dll assembly, version 1.0.0.0. There is a security bug in that assembly, and I publish the patch, issuing it under name myapp.dll 1.1.0.0. How do I tell the client applications that are already installed to start using this new myapp.dll?

498


What is the difference between system.string and system.text.stringbuilder classes?

528


Define thread?

593


What type is string in c#?

491


Explain the difference between boxing and unboxing.

541


How to implement an object pool in c#.net.

563


What is the difference between ienumerable and icollection?

476


Can you see a loop recorder?

505


What does immutable mean in c#?

512