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 is the use of delegates in c#?
Which are the loop types available in c#?
what are windows services?
What is a must for multitasking
How many aware interfaces are there?
Define acid rule of thumb for transactions in c#.
How do you declare an interface in c#?
Can we create extension method for interface?
What is dictionary collection in c#?
What are the extension methods in c#?
Why do we use struct in c#?
How many types of constructors are there in c#?
What is the difference between an application domain and a process?
What are the collection types can be used in c#?
What is the main method in c#?