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 the example of predicate?

0 Answers  


What is data adapter in c#?

0 Answers  


Why is static constructor called first?

0 Answers  


what is the difference between interface and multiple interface?

0 Answers   Wipro,


What is private in c#?

0 Answers  


How can i Spawn a Thread

0 Answers   HCL,


Does c# support templates?

0 Answers  


What is the difference between read and readline in c#?

0 Answers  


Why do we need interface in c#?

0 Answers  


How to find type of variable?

0 Answers   HCL,


how to sort an array in c#

0 Answers   Cognizant,


ctype(123.34,integer) - should it throw an error? Why or why not?

2 Answers   Wipro,


Categories