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
Can we have multiple constructors in a class c#?
What is Web.config?
What is inline function in c#?
What is platform independence"?
Define thread?
Why do we need constructors?
What is the use of console readkey ()?
What does out mean in c#?
What is a type c#?
Can abstract class have constructor in c#?
Is everything an object c#?
How to add a readonly property in c#.net
What is the difference between console application and windows application?
what is the Difference between the public and private ?
What are delegates in C#?