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
What are collections in c#?
What is the main purpose of xml?
Why main method is static in c#?
What is hashtable c#?
What is a console application in c#?
Are tuples immutable c#?
Can destructors have access modifiers?
What are virtual classes in c#?
What is 8 bit signed integer?
When should we use sealed class in c#?
What is dependency injection in simple words?
Can you declare struct members as protected?
Explain About Iunknown interface Queue
How do I do implement a trace?
What is dataadapter c#?