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



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

Answer / 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

More C Sharp Interview Questions

What is delegates & multicast delegate?

2 Answers   Cognizant,


i want the csharp questions&answeres

0 Answers   IBM, Siemens,


Are c# strings null terminated?

0 Answers  


What is ac callback?

0 Answers  


Advantages of c# over vb.net?

3 Answers   HCL, Syntel,






Define c# delegate?

0 Answers  


how to insert the data from the grid view to database table though button click.pls send the answer to mail id suri1319@gmail.com

0 Answers  


What is the use of 'using' statement in c#?

0 Answers  


How does substring work in c#?

0 Answers  


What is the use of 'as' Keyword in C# ?

0 Answers   HCL,


In c#, what will happen if you do not explicitly provide a constructor for a class?

0 Answers  


Define Final Class in C#

0 Answers   HCL,


Categories