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 use of list in c#?
What are types of constructor?
I want to print "Hello" even before main() is executed. How will you achieve that?
What is the delegates in c#?
What is strong data type in c#?
What is int64 in c#?
What method is used to sort the elements of the array in descending order?
What is an object pool in .net?
Difference between StackPanel and RelativePanel ?
What are the fundamental principles of oo programming?
How can you reference current thread of the method ?
What is sorting in c#?
What are the 2 broad classifications of data types available in c#?
What is Reflection in .NET? Namespace? How will you load an assembly which is not referenced by current assembly?
Distinguish between continue and break statement?