| |
|
What is IDisposable interface in .NET?
IDisposable interface - We implement this interface to a class when we have to work with
unmanaged types. For example, an IntPtr member representing an operating system's file handler
is actually unmanaged, and in order to destroy it, we make use of the Dispose method by
implementing the IDisposable interface. In this case, we override the Finalize method.
Note that we make use of Dispose method on those objects which have an uncertain life period,
and thus the garbage collector does not finalize them automatically.
We also make use of Dispose method while working with managed code, for example, an object os
System.IO.FileStream may have an uncertain life, and in order to dispose it, we use the
dispose method. Such types of objects are not accessed by the Garbage Collector's Finalizer.
.NET
Languages
Versions
Tools
CLI CTS Metadata CLS IL VES
CLR
Class Library
Managed Class
Assembly ILDASM
Reflection
Assembly Types
Strong Assembly
GAC
GC
IDisposable
Serialization
Code Access Security
Attribute
Thread
Globalization
Generations
COM
| |