Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren0
Automatic Destruction
why is the object dog automatically destroyed? Does this happen when the program has finished running? where is the command to destroy the object?
2 Antworten
+ 9
An object is destroyed once its scope has ended. Objects and variables only last for the code block they're inside (a method, if/for/while, class, etc.).
Ex: If the dog object were declared inside a method, once that method ended, that dog object would no longer be usable and would be destroyed.
+ 2
I believe this is something the C# language is known for - its automatic garbage disposal