
How can you force Dispose method to be called automatically in .NET?Sometimes
you might forget to call the Dispose method in your code but you might
require it. Here is a
sample code in C# to demonstrate it: public class
sampleClass:IDisposable { In this example,
you release the unmanaged resource namely sampleReader from inside Dispose
method and you call Dispose method from inside the destructor. This is
because you cannot override Finalize method directly in C#. In VB.NET,
you will be calling Dispose method from inside Finalize method as shown
below: Overrides
Sub Finalize()
_______________________________________________________________________
FREE
Subscription
Subscribe
to our mailing list and receive new articles Note
: We never rent, trade, or sell my email lists to Visit
.NET Programming Tutorial Homepage ______________________________________________________ |