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

How can I produce an assembly?

0 Answers  


Explain circular reference in c#?

0 Answers  


Can we customize the serialization process?

0 Answers  


What is data quality assurance?

0 Answers  


What is difference between continue and break in c#?

0 Answers  






What are the two kinds of properties?

10 Answers   Wipro,


Why is the XML InfoSet specification different from the Xml DOM? What does the InfoSet attempt to solve ?

1 Answers  


What is a satellite assembly in c#?

0 Answers  


Are tuples mutable c#?

0 Answers  


What is c# used for in the industry?

0 Answers  


What is the difference while using directive vs using statement ?

0 Answers  


How can you overload a method?

3 Answers  


Categories