0
How can we say that the object is destroyed or how the destructor be called?
3 Answers
+ 1
you can destroy it by setting it variable=null;
that way the garbage collector will dispose it.
but you don't need to do it that much because the garbage collector is smart enough to know if you're not going to use the object anymore.
except if the object last use is in a loop. the garbage collector will only notice if you don't use it and destroy it after the loop ends unless you set it to null.
oh, and you can't have any other reference to that object. for example. two objects pointing to the same class. if you set one to null. the garbage collector won't do anything unless you set the other too.
0
Because this is a console application all code will be ran through and then the application ends and this includes the destructors
0
juste make it do something to be sure it's called. for example write something in a file. or check in the memory. easy to do if you are using vs2015