This is the special member function of a class, which is executed whenever an object of its class goes out of scope. Destructor is use to releasing resources before coming out the problem like closing files releasing memories. See in given below example.
Example
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace work_for_destructor_in_c_sarp
{
class height
{
private double ht;
public height() /*Create constructor */
{
Console.WriteLine("Object create");
}
~height() /*Create Destructor */
{
Console.WriteLine("Object is deleted");


Join the conversation! Your thoughts help the community grow.