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
Why do we need interface in c#?
What do you mean by shared assembly?
What is an iqueryable in c#?
How long will it take to learn c#?
How do you implement thread synchronization (object.wait, notify,and criticalsection) in c#?
Can you declare struct members as protected?
What standard types does c# use?
Is std :: string null terminated?
What is private static in c#?
Explain concurrency with aop?
Do void methods have parameters?
What is the difference between writeline and write in c#?
What is a base class in C#?
What is asenumerable in c#?
Are multiple data types stored in System.Array?