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

Can struct inherit from class c#?

696


If c# destructors are so different to c++ destructors, why did ms use the same syntax?

696


Why do we use dataset in c#?

665


Define c# i/o classes? List the commonly used classes?

720


What are the advantages of using partial classes?

698






How does insertion sort work?

695


What is the namespace for datatable in c#?

698


Is and as keyword in c# net?

713


What is the difference between struct and class in c#?

682


Can we inherit a class with private constructor in c#?

797


Contrast between an interface and abstract class?

721


How do you declare an arraylist?

678


What is the difference between constants and read-only?

662


How main method is called in c#?

680


What is dependency in software?

689