How u call destructor and dispose methode in c#.NET

Answer Posted / ruchika mathur

Destructor: They are special methods that contain the
cleanup code for the object.You cannot call them explicitly
as they are called by GC implicitly.
Class MyClass
{
~MyClass()
{
}
}

public interface IDisposable
{
void Dispose();
}
Class Test:IDisposable
{
protected void Dispose()
{
if(disposing)
{
// Code to dispose the managed resources of the class
}
// Code to dispose the un-managed resources of the class

isDisposed = true;
}

public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}


}
}

Is This Answer Correct ?    2 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can we have multiple constructors in a class c#?

584


What is Web.config?

629


What is inline function in c#?

599


What is platform independence"?

624


Define thread?

663






Why do we need constructors?

588


What is the use of console readkey ()?

611


What does out mean in c#?

605


What is a type c#?

575


Can abstract class have constructor in c#?

584


Is everything an object c#?

576


How to add a readonly property in c#.net

586


What is the difference between console application and windows application?

581


what is the Difference between the public and private ?

598


What are delegates in C#?

644