C# .NET - Should i write the Dispose method for user defined class explicitly?

Asked By Nagaraj muthuchamy on 25-Sep-07 03:01 AM
Should we write the dispose method for user defined class?
How the clr disposes user defined class objects?

thank you
nagaraj

You only need to implement IDisposable

Peter Bromberg replied to Nagaraj muthuchamy on 25-Sep-07 07:38 AM

When there is some non-managed reference to dispose - database connections, file handles, and so on -- or if you have a reference to a library that implements IDisposable.

Most user-defined classes DO NOT need to implement IDisposable.

I got it

Nagaraj muthuchamy replied to Peter Bromberg on 25-Sep-07 08:20 AM
thank you very much , I got it

Nagaraj