Some Q about lecture 65

Hello everyone!
So I have some question about the code in the lesson:

  1. Can someone explain me who on this line
    The computer know that we mean destroy MusicPlayer?
  2. Can u please explain what “that” in this line of code mean?
    instance = this;
    Thanks u all and sorry for me bad english :blush:
1 Like

Hello @IamIdan,

Speaking generally regarding the code you have posted;


The Destroy method is passed an object reference to dispose of, in this case you are passing it a reference of otherObject, if this is a MusicPlayer object then in your code there will be some code setting otherObject to equal an instance of the MusicPlayer.

Some documentation regarding Destroy for you and an an example at runtime.

instance = this;

this simply refers to the current instance of the object, so if I wanted to set some variables within the current object I may use some code like this;

this.playerName = "Rob";
this.playerLives = 3

This would be from within an object called perhaps Player.

Here’s some C# documentation which should help also.

Don’t forget if you have questions regarding a specific lecture you can use the Q&A within the Udemy site where you will get answers from your instructors along with potentially other students on the same lecture.

Hope this helps.


Go Rob! What an amazing detailed response

1 Like

Thanks Ben, just trying to help where I can, it’s good for my grey matter at the moment too :slight_smile:


I have re-tagged this post using the new lecture tag system. Remember the easiest way to get your lecture-specific posts in the right sub-category and tag is use the new “Lecture DISCUSSIONS” link in the Udemy Resources. It takes you right to the right place here in the forum.

Privacy & Terms