odiseh
odiseh

Reputation: 26517

close, dispose, finalize, GC, Idisposable,.... have you got a clear description of them?

i am completely confused about close, dispose, finalize, GC, Idisposable. Oh, could you please send me a clear description of them?

Upvotes: 1

Views: 1468

Answers (1)

Brian Rasmussen
Brian Rasmussen

Reputation: 116401

That is a fairly large topic. May I recommend the book CLR via C# by Richter. It goes into details about all the issues you mention.

A very brief translation:

  • On disposable types Close is often the same as Dispose.
  • Dispose is used to allow deterministic clean up of resources not handled by garbage collection.
  • Finalizer (or destructor as the C# language spec calls it) is a clean-up method called by the garbage collection code at some point in time. I.e. unlike destructors for C++ this is not done at a well defined point in time.
  • GC is short for garbage collection and refers to .NET's automatic clean-up of objects located on the managed heap.
  • IDisposable is an interface, that states that the type in question implements the Dispose method as outlined above.

For more details please consult the book. This rather elaborate blog entry by Joe Duffy is also very useful for understanding IDisposable and finalizers.

Upvotes: 5

Related Questions