0

Can we destroy an instantiated object manually and call its destructor before we exit the scope which it was declared? (C#)

In the course they showed a piece of code like this: Dog d = new Dog(); and it would output this: "Animal created. Dog created. Dog destroyed. Animal destroyed." I tried doing this: d = null; GC.Collect(); Console.WriteLine("Dog"); But the Dog and Animal destructors are always called last when program ends, is there a way to call them manually? I hope I explained well.

15th Feb 2017, 9:58 PM
SIMOMEGA
SIMOMEGA - avatar
2 Réponses
0
Thx!
16th Feb 2017, 9:29 AM
SIMOMEGA
SIMOMEGA - avatar
Aujourd'hui en vedette
.
1 Votes
What?
0 Votes
HTML
0 Votes
Web
0 Votes
Quiz duel
0 Votes
FRC Coding?
1 Votes
help
0 Votes
AI
2 Votes
APIs
1 Votes