Tuesday 11 August 2015

What is Destructor in C#.Net

 A Destructor  is also a method which gets called whenever the object of  class is destroyed which is an opposite to a constructor which gets called an object is created.
       Destructor method also as the same name of a class. But prefixed with tild (~)operator.

Example : 

             Class test
           {
               test()
               {
                    // Constructor
               }
                 ~test()

                {
                    //Destructor  
                 } 
                }
Destructor  method cannot have any modifiers as well as  cannot have any input parameter.

              

No comments:

Post a Comment