How u call destructor and dispose methode in c#.NET
Answer / 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 |
What happens if the inherited interfaces have conflicting method names?
What is access modifier in c#?
Can we return two values from a function?
what is collections in .net? why we use?
Define boxing and unboxing in c#?
Can fields inside a class be virtual?
What is the difference between a variable and a literal?
What is cookies in c# asp net?
What are Custom Control and User Control?
Why do we override in c#?
Why do we need constructor in c#?
What is deferred execution in c#?