0

How to delete a class object in Console application?

I want to see the use of Destructor that's why I need to delete object of the class that has a Destructor. Please some one help me throw an example related to it. I don't know writing English with the use of proper grammar so try to understand my speech.

11th Jan 2017, 5:23 AM
Habibur Rahman
Habibur Rahman - avatar
1 Réponse
+ 1
C# has automatic garbage collector working in the background to collect objects that are not required. Therefore, there is no need to call delete explicitly. namespace SoloLearn { class Program { static void Main(string[] args) { A aObj = new A(); } } class A { ~A() { Console.WriteLine("Destructor Called"); } } } //Displays Destructor Called 'aObj' is not needed once it goes out of scope of Main method
11th Jan 2017, 11:51 AM
crocs