What is a Destructor in C#?
- A Destructor is used to clean up the memory and free the resources. But in C# this is done by the garbage collector on its own. System.GC.Collect() is called internally for cleaning up. But sometimes it may be necessary to implement destructors manually.
Ex :
~Car()
{
Console.writeline(“….”);
}
No comments