Hello, buddies. I have some bad news for ya. We’ll have to look at the way your app is stored in RAM. No-no-no, don’t close the video. We won’t consider all of the details. We need to get familiar with some basic things to be able to understand further topics. Okat, let’s start with Heap. What hapens when your app starts? Well, the processor allocated some amount of memory in RAM, that is limited ot the number of physical slots on your motherboard and their size (volume). This memory is called the Heap.
We can put new objects there and get them back. Let’s image a library. There is a card storage – each book has it’s own card. There is an address of the row and place of this book. So that you can easily find it. There is a card with the address and a physical object – the book,
that can easlily be found by it’s address. Now when we create an instance of a class There happens some memory allocation in heap Where all object’s members are (or will be) located. And the variable itself stores not the object, but the link (pointer/reference) to the object in heap. To sum up – the link (pointer/reference) is the address of the object in RAM. I’ll show you an example. First we create the class with a property of type int called Id. Then we create an instance of this class and assign it some value.
(I guess the author means assigning value to Id property) Now we’ll create a void method e.g. ChangeId(), and don’t forget to make it static. Inside we’ll just assign a new value to Id property. Then we’ll call this method with a link (pointer/reference) to a Book object as a parameter. Then we’ll print book’s id. Now, guys, try to guess, what’s gonna happen.