Understanding Boxing in C#
Read full transcript 24 segments
-
You may have heard the term boxing in C, You may have heard the term boxing in C, but do you know what it means? And do but do you know what it means? And do but do you know what it means? And do you know what the implications of boxing you know what the implications of boxing you know what the implications of boxing are for your application? Boxing is when are for your application? Boxing is when are for your application? Boxing is when you convert an item from a stack item to you convert an item from a stack item to you convert an item from a stack item to a heap element, essentially putting it a heap element, essentially putting it a heap element, essentially putting it in a box. This can have performance in a box. This can have performance in a box. This can have performance implications for your application, but implications for your application, but implications for your application, but it may not be obvious that it's it may not be obvious that it's it may not be obvious that it's happening. In this video, we're going to happening. In this video, we're going to happening. In this video, we're going to see when boxing occurs, understand what see when boxing occurs, understand what see when boxing occurs, understand what to do when it happens, and see why to do when it happens, and see why to do when it happens, and see why generics are so important for avoiding generics are so important for avoiding generics are so important for avoiding boxing and more. Now, if you don't know boxing and more. Now, if you don't know boxing and more. Now, if you don't know me, my name is Tim Corey, and my goal is me, my name is Tim Corey, and my goal is me, my name is Tim Corey, and my goal is to help you become the best developer to help you become the best developer to help you become the best developer you can be. Instead of faking it or you can be. Instead of faking it or you can be. Instead of faking it or pretending that prompting an AI makes pretending that prompting an AI makes pretending that prompting an AI makes you a good developer, I will teach you you a good developer, I will teach you you a good developer, I will teach you how to be a confident, prepared how to be a confident, prepared how to be a confident, prepared developer, ready to survive and thrive developer, ready to survive and thrive developer, ready to survive and thrive in today's marketplace. This channel has in today's marketplace. This channel has in today's marketplace. This channel has over a thousand videos dedicated to just over a thousand videos dedicated to just over a thousand videos dedicated to just that. But if you're looking for even that. But if you're looking for even that. But if you're looking for even more, go to devforge.com. There you'll more, go to devforge.com. There you'll more, go to devforge.com. There you'll find even more free and paid resources find even more free and paid resources find even more free and paid resources to help you wherever you are on the to help you wherever you are on the to help you wherever you are on the development journey. All right, let's development journey. All right, let's development journey. All right, let's jump right into our application. This is jump right into our application. This is jump right into our application. This is a net 10 console application. If you're a net 10 console application. If you're a net 10 console application. If you're on net 11, cool. Use 11. Doesn't really on net 11, cool. Use 11. Doesn't really on net 11, cool. Use 11. Doesn't really matter. We're gonna see a very basic matter. We're gonna see a very basic matter. We're gonna see a very basic demo. We're going to start with int a demo. We're going to start with int a demo. We're going to start with int a equals 5. Now a is a value type here.
-
equals 5. Now a is a value type here. equals 5. Now a is a value type here. Now if you don't know value type versus Now if you don't know value type versus Now if you don't know value type versus reference type, I have a video on that. reference type, I have a video on that. reference type, I have a video on that. Go back a few videos, you'll see it. Um, Go back a few videos, you'll see it. Um, Go back a few videos, you'll see it. Um, also I have a video on garbage also I have a video on garbage also I have a video on garbage collection. It will be helpful as well. collection. It will be helpful as well. collection. It will be helpful as well. Those two will really be good kind of Those two will really be good kind of Those two will really be good kind of prerequisites for this video, but you prerequisites for this video, but you prerequisites for this video, but you can just watch this as a standalone and can just watch this as a standalone and can just watch this as a standalone and understand what's going on. Okay, so understand what's going on. Okay, so understand what's going on. Okay, so object B equals A. Now object B is going object B equals A. Now object B is going object B equals A. Now object B is going to store A which is an integer. But to store A which is an integer. But to store A which is an integer. But since object is on the heap, what since object is on the heap, what since object is on the heap, what happens is we create a box to put our happens is we create a box to put our happens is we create a box to put our integer into. So this is what's called integer into. So this is what's called integer into. So this is what's called boxing. Now if I were to say console boxing. Now if I were to say console boxing. Now if I were to say console right line and just say B, what do you right line and just say B, what do you right line and just say B, what do you think it's going to print out there? think it's going to print out there? think it's going to print out there? Well, it's going to be pretty Well, it's going to be pretty Well, it's going to be pretty straightforward. It's going to print out straightforward. It's going to print out straightforward. It's going to print out five. And there we go. So, it looks like five. And there we go. So, it looks like five. And there we go. So, it looks like nothing happened, but behind the scenes, nothing happened, but behind the scenes, nothing happened, but behind the scenes, what happened is, let's go to our um our what happened is, let's go to our um our what happened is, let's go to our um our drawing here. We had this five, right?
-
drawing here. We had this five, right? drawing here. We had this five, right? And that's that's our integer five. And that's that's our integer five. And that's that's our integer five. [snorts] But when we put it into object [snorts] But when we put it into object [snorts] But when we put it into object B, what we did is he put a box around B, what we did is he put a box around B, what we did is he put a box around that and put on the heap and then put a that and put on the heap and then put a that and put on the heap and then put a pointer to it that lives on the stack. pointer to it that lives on the stack. pointer to it that lives on the stack. So this pointer says, "Hey, this is So this pointer says, "Hey, this is So this pointer says, "Hey, this is where you can find object B which where you can find object B which where you can find object B which contains an integer. contains an integer. contains an integer. Now we can use that in our console right Now we can use that in our console right Now we can use that in our console right line without really a problem. line without really a problem. line without really a problem. Although what's going on behind the Although what's going on behind the Although what's going on behind the scenes a little interesting? Let's make scenes a little interesting? Let's make scenes a little interesting? Let's make it a little more obvious. What if I said it a little more obvious. What if I said it a little more obvious. What if I said B plus A? Well, I can't do that. Even B plus A? Well, I can't do that. Even B plus A? Well, I can't do that. Even though both of these are integers, though both of these are integers, though both of these are integers, because technically B is not an integer, because technically B is not an integer, because technically B is not an integer, it's an object. So, right at design it's an object. So, right at design it's an object. So, right at design time, it gives me an error saying, "Hey, time, it gives me an error saying, "Hey, time, it gives me an error saying, "Hey, I can't compile this. This won't work." I can't compile this. This won't work." I can't compile this. This won't work." So, what do you do? Well, you unbox it. So, what do you do? Well, you unbox it. So, what do you do? Well, you unbox it. So, we take the int out of the box and So, we take the int out of the box and So, we take the int out of the box and put it back into an integer. To do that, put it back into an integer. To do that, put it back into an integer. To do that, we say int parenthesis in front of it.
-
we say int parenthesis in front of it. we say int parenthesis in front of it. We've taken B. Now the value of B that's We've taken B. Now the value of B that's We've taken B. Now the value of B that's inside of B, we've taken that out of the inside of B, we've taken that out of the inside of B, we've taken that out of the box and made it back into a value type, box and made it back into a value type, box and made it back into a value type, an integer which we can add to A. And if an integer which we can add to A. And if an integer which we can add to A. And if we run this now, we can see 10. It we run this now, we can see 10. It we run this now, we can see 10. It works. works. works. But what if we did this? What if, and But what if we did this? What if, and But what if we did this? What if, and let's uh duplicate this line. By the let's uh duplicate this line. By the let's uh duplicate this line. By the way, you can get the source code for way, you can get the source code for way, you can get the source code for this in the description. So if you want this in the description. So if you want this in the description. So if you want a copy of this to play around with, go a copy of this to play around with, go a copy of this to play around with, go ahead and download that. So let's go ahead and download that. So let's go ahead and download that. So let's go back here and let's do this. Let's say a back here and let's do this. Let's say a back here and let's do this. Let's say a / two. Now remember a is our integer. / two. Now remember a is our integer. / two. Now remember a is our integer. We're going to start off with a baseline We're going to start off with a baseline We're going to start off with a baseline understand of what this division does. understand of what this division does. understand of what this division does. So it says two. Well, why two? Because So it says two. Well, why two? Because So it says two. Well, why two? Because it's an integer and integers are whole it's an integer and integers are whole it's an integer and integers are whole numbers. So we divide by two. 5 / two is numbers. So we divide by two. 5 / two is numbers. So we divide by two. 5 / two is 2.5. But that's a double. And we can't 2.5. But that's a double. And we can't 2.5. But that's a double. And we can't have a double. We have to have an have a double. We have to have an have a double. We have to have an integer. So it drops the decimal. What's integer. So it drops the decimal. What's integer. So it drops the decimal. What's ever after the decimal just says two.
-
ever after the decimal just says two. ever after the decimal just says two. But what if we wanted to change that? But what if we wanted to change that? But what if we wanted to change that? Well, for an integer like this, we can Well, for an integer like this, we can Well, for an integer like this, we can say double in front of it. Basically say double in front of it. Basically say double in front of it. Basically declaring that, yeah, I know it's an declaring that, yeah, I know it's an declaring that, yeah, I know it's an integer, but actually treat it as a integer, but actually treat it as a integer, but actually treat it as a double. And if we do this, we now see double. And if we do this, we now see double. And if we do this, we now see the result is 2.5. Now, just to be the result is 2.5. Now, just to be the result is 2.5. Now, just to be clear, you could have put double in clear, you could have put double in clear, you could have put double in front of two. That would have worked as front of two. That would have worked as front of two. That would have worked as well. But this is for a demo purpose. well. But this is for a demo purpose. well. But this is for a demo purpose. Okay. So we now have seen how to do this Okay. So we now have seen how to do this Okay. So we now have seen how to do this with an integer. Let's see how to do with an integer. Let's see how to do with an integer. Let's see how to do this with our object B. So console right this with our object B. So console right this with our object B. So console right line we're going to say we're going to line we're going to say we're going to line we're going to say we're going to start off with what we think is going to start off with what we think is going to start off with what we think is going to be the case. Uh let's start with just B be the case. Uh let's start with just B be the case. Uh let's start with just B divided by two. And we can see the divided by two. And we can see the divided by two. And we can see the error. Okay, not a problem. We want this error. Okay, not a problem. We want this error. Okay, not a problem. We want this to be a double anyway. So let's just do to be a double anyway. So let's just do to be a double anyway. So let's just do double. And notice there's no error. Now double. And notice there's no error. Now double. And notice there's no error. Now if I run this it crashes why this is a if I run this it crashes why this is a if I run this it crashes why this is a runtime error not a design time error runtime error not a design time error runtime error not a design time error like you see before the runtime error like you see before the runtime error like you see before the runtime error says hey I can't cast object of type says hey I can't cast object of type says hey I can't cast object of type int32 to system double now I could do int32 to system double now I could do int32 to system double now I could do that with this integer that with this integer that with this integer I could just say double but because I could just say double but because I could just say double but because we're in a boxing situation what happens we're in a boxing situation what happens we're in a boxing situation what happens is let's draw this out we have our is let's draw this out we have our is let's draw this out we have our number five and it's in the box.
-
number five and it's in the box. number five and it's in the box. We cannot then do any work on this We cannot then do any work on this We cannot then do any work on this number five while it's in the box. We number five while it's in the box. We number five while it's in the box. We first have to take it out of the box, first have to take it out of the box, first have to take it out of the box, unbox it, and convert it back into our unbox it, and convert it back into our unbox it, and convert it back into our integer and then we can do work on it to integer and then we can do work on it to integer and then we can do work on it to say actually it's 5.0 say actually it's 5.0 say actually it's 5.0 a double. Okay, so how do you do that a double. Okay, so how do you do that a double. Okay, so how do you do that here? Well, what you do is you first here? Well, what you do is you first here? Well, what you do is you first start off by saying int. Okay, so and start off by saying int. Okay, so and start off by saying int. Okay, so and this is going to work. It's going to say this is going to work. It's going to say this is going to work. It's going to say two, which is close to what you want, two, which is close to what you want, two, which is close to what you want, but not correct. What you need to do but not correct. What you need to do but not correct. What you need to do instead is put in front of it double. instead is put in front of it double. instead is put in front of it double. So, double int / two, which does work. So, double int / two, which does work. So, double int / two, which does work. 2.5. But why does it work? Well, because 2.5. But why does it work? Well, because 2.5. But why does it work? Well, because this first step here is taking it out of this first step here is taking it out of this first step here is taking it out of the box. Then this next step here is the box. Then this next step here is the box. Then this next step here is saying actually treat it like a double saying actually treat it like a double saying actually treat it like a double instead of an integer. So we can't do instead of an integer. So we can't do instead of an integer. So we can't do those two steps in one. We have to do it those two steps in one. We have to do it those two steps in one. We have to do it in two steps. Take it out of the box and in two steps. Take it out of the box and in two steps. Take it out of the box and then do something with it. Cast it back then do something with it. Cast it back then do something with it. Cast it back to the correct type and then do to the correct type and then do to the correct type and then do something with that type. Okay, so something with that type. Okay, so something with that type. Okay, so that's one of those this will trip you that's one of those this will trip you that's one of those this will trip you up things if you're not careful. Okay, up things if you're not careful. Okay, up things if you're not careful. Okay, speaking of tripping you up, let's um speaking of tripping you up, let's um speaking of tripping you up, let's um let's get a few more lines here. Um I'm let's get a few more lines here. Um I'm let's get a few more lines here. Um I'm going to put one more object here.
-
going to put one more object here. going to put one more object here. Object C equals 5. Now B equals 5 and C Object C equals 5. Now B equals 5 and C Object C equals 5. Now B equals 5 and C equals 5 and they're both boxed. So if I equals 5 and they're both boxed. So if I equals 5 and they're both boxed. So if I were to say console right line B equals were to say console right line B equals were to say console right line B equals C. C. C. What should I get? True or false here? What should I get? True or false here? What should I get? True or false here? Think about it. Let's find out. We get Think about it. Let's find out. We get Think about it. Let's find out. We get false. Why do we get false when they false. Why do we get false when they false. Why do we get false when they both have an integer with the value of both have an integer with the value of both have an integer with the value of five inside them? Well, because both of five inside them? Well, because both of five inside them? Well, because both of these are heap elements. They're not these are heap elements. They're not these are heap elements. They're not stack items, which means that we don't stack items, which means that we don't stack items, which means that we don't just have a a value. We actually have just have a a value. We actually have just have a a value. We actually have our integer. We put that in a box. our integer. We put that in a box. our integer. We put that in a box. That's our object. But then we have this That's our object. But then we have this That's our object. But then we have this pointer that goes to it. So the pointer pointer that goes to it. So the pointer pointer that goes to it. So the pointer on the stack points to the correct box. on the stack points to the correct box. on the stack points to the correct box. So let's just say this is box B. Well, So let's just say this is box B. Well, So let's just say this is box B. Well, when we create box C, we create a when we create box C, we create a when we create box C, we create a separate box. separate box. separate box. and we put five inside that box and we and we put five inside that box and we and we put five inside that box and we have a separate pointer that points to have a separate pointer that points to have a separate pointer that points to that box. This is C. So when we say is that box. This is C. So when we say is that box. This is C. So when we say is this pointer right here, is that equal this pointer right here, is that equal this pointer right here, is that equal to this pointer? Well, no, they're not.
-
to this pointer? Well, no, they're not. to this pointer? Well, no, they're not. They're different pointers. They're They're different pointers. They're They're different pointers. They're pointed different places in the memory. pointed different places in the memory. pointed different places in the memory. And the elements inside there aren't And the elements inside there aren't And the elements inside there aren't actually getting compared. It's just the actually getting compared. It's just the actually getting compared. It's just the reference getting compared. And we have reference getting compared. And we have reference getting compared. And we have a whole thing on equality. I have a a whole thing on equality. I have a a whole thing on equality. I have a video on that in in comparison. You'll video on that in in comparison. You'll video on that in in comparison. You'll see this actual example there. Okay. So see this actual example there. Okay. So see this actual example there. Okay. So what do we do here? Well, we have to what do we do here? Well, we have to what do we do here? Well, we have to remember that these are objects and not remember that these are objects and not remember that these are objects and not the the types. So if you wanted to the the types. So if you wanted to the the types. So if you wanted to really do a comparison, we have to cast really do a comparison, we have to cast really do a comparison, we have to cast it back to its original type. Unbox it. it back to its original type. Unbox it. it back to its original type. Unbox it. So in this case, we can unbox it and So in this case, we can unbox it and So in this case, we can unbox it and then we do a comparison. They're true then we do a comparison. They're true then we do a comparison. They're true because we're we're we're comparing the because we're we're we're comparing the because we're we're we're comparing the values of the two because these are values of the two because these are values of the two because these are value types. Now, we've unboxed them and value types. Now, we've unboxed them and value types. Now, we've unboxed them and they're back to five and five and that they're back to five and five and that they're back to five and five and that those are equal. Okay, so that's the those are equal. Okay, so that's the those are equal. Okay, so that's the basics of boxing. And if you ever have basics of boxing. And if you ever have basics of boxing. And if you ever have an interview or whatever else that you an interview or whatever else that you an interview or whatever else that you know asks you about boxing, now you know know asks you about boxing, now you know know asks you about boxing, now you know how boxing and unboxing works. But let's how boxing and unboxing works. But let's how boxing and unboxing works. But let's go a step further in this and let's go a step further in this and let's go a step further in this and let's understand about strrus because a understand about strrus because a understand about strrus because a strruct is a value type. Now it looks an strruct is a value type. Now it looks an strruct is a value type. Now it looks an awful lot like a class. In fact, what awful lot like a class. In fact, what awful lot like a class. In fact, what we're going to do for this demo is first we're going to do for this demo is first we're going to do for this demo is first create a class. I'm also going to create create a class. I'm also going to create create a class. I'm also going to create a interface for it. Um let's call create a interface for it. Um let's call create a interface for it. Um let's call create the interface first.
-
the interface first. the interface first. public interface I counter. public interface I counter. public interface I counter. And in here we're going to say int count And in here we're going to say int count And in here we're going to say int count and we'll put a get and a set. We could and we'll put a get and a set. We could and we'll put a get and a set. We could just do a a read only. Uh but I'm going just do a a read only. Uh but I'm going just do a a read only. Uh but I'm going to do a read write and void increment to do a read write and void increment to do a read write and void increment count is a method. So that's that's an count is a method. So that's that's an count is a method. So that's that's an interface. And I'm going to do is I'm interface. And I'm going to do is I'm interface. And I'm going to do is I'm going to say public class counter going to say public class counter going to say public class counter implements I counter. implements I counter. implements I counter. And right now it doesn't. So let's go And right now it doesn't. So let's go And right now it doesn't. So let's go ahead and say control.implement. ahead and say control.implement. ahead and say control.implement. implement the interface. There's our implement the interface. There's our implement the interface. There's our property. And here what we're going to property. And here what we're going to property. And here what we're going to do is just say count plus+. do is just say count plus+. do is just say count plus+. So really simple class. There's just one So really simple class. There's just one So really simple class. There's just one method and one property. Okay. Now method and one property. Okay. Now method and one property. Okay. Now again, we're going to talk strrus in again, we're going to talk strrus in again, we're going to talk strrus in just a minute, but first let's talk just a minute, but first let's talk just a minute, but first let's talk about classes because you probably are about classes because you probably are about classes because you probably are familiar with how classes work and I familiar with how classes work and I familiar with how classes work and I want to start with that baseline. want to start with that baseline. want to start with that baseline. So I'm going to say counter call counter So I'm going to say counter call counter So I'm going to say counter call counter one equals new. And then let's put the one equals new. And then let's put the one equals new. And then let's put the count equal to three to start. That's count equal to three to start. That's count equal to three to start. That's why I made it uh read right. And I'm why I made it uh read right. And I'm why I made it uh read right. And I'm going to say I counter going to say I counter going to say I counter counter 2 equals counter one. And I counter 2 equals counter one. And I counter 2 equals counter one. And I shouldn't have put a space there. Okay.
-
shouldn't have put a space there. Okay. shouldn't have put a space there. Okay. So what am I doing here? Well, this is a So what am I doing here? Well, this is a So what am I doing here? Well, this is a class counter one. and I am casting it class counter one. and I am casting it class counter one. and I am casting it to type I counter. Now for a class, to type I counter. Now for a class, to type I counter. Now for a class, what's happening? Well, again, let's get what's happening? Well, again, let's get what's happening? Well, again, let's get out our our little demo here. A class out our our little demo here. A class out our our little demo here. A class represented by, you know, this box right represented by, you know, this box right represented by, you know, this box right here. So, we have the the stuff inside here. So, we have the the stuff inside here. So, we have the the stuff inside the box. That's the class instance. And the box. That's the class instance. And the box. That's the class instance. And we have this pointer that points to it. we have this pointer that points to it. we have this pointer that points to it. Well, I counter 2 still points to this Well, I counter 2 still points to this Well, I counter 2 still points to this same box, but it's using the interface same box, but it's using the interface same box, but it's using the interface as the definition. as the definition. as the definition. So the I can't really write here. Um So the I can't really write here. Um So the I can't really write here. Um sorry my handwriting is atrocious. Um sorry my handwriting is atrocious. Um sorry my handwriting is atrocious. Um I'm using a mouse. Um but this is my I'm using a mouse. Um but this is my I'm using a mouse. Um but this is my interface, right? So they both point to interface, right? So they both point to interface, right? So they both point to the same location. It's just the the same location. It's just the the same location. It's just the interface has a contract and that interface has a contract and that interface has a contract and that contract says these are the things you contract says these are the things you contract says these are the things you will and won't do or have. So it's the will and won't do or have. So it's the will and won't do or have. So it's the same object in memory. It's just pointed same object in memory. It's just pointed same object in memory. It's just pointed to in a different way. So if I were to to in a different way. So if I were to to in a different way. So if I were to come down here and say counter 2 come down here and say counter 2 come down here and say counter 2 increment count and let's duplicate that increment count and let's duplicate that increment count and let's duplicate that and do it twice and then let's say uh and do it twice and then let's say uh and do it twice and then let's say uh console right line and we'll do a string console right line and we'll do a string console right line and we'll do a string interpolation here and say uh counter interpolation here and say uh counter interpolation here and say uh counter one and then say counter one and then say counter one and then say counter one count.
-
one count. one count. Let's duplicate this line and say Let's duplicate this line and say Let's duplicate this line and say counter two and counter two.count. counter two and counter two.count. counter two and counter two.count. What do you think counter one and What do you think counter one and What do you think counter one and counter 2's values are going to be? I counter 2's values are going to be? I counter 2's values are going to be? I only incremented counter 2's values. only incremented counter 2's values. only incremented counter 2's values. Now, I'll give you just a second to Now, I'll give you just a second to Now, I'll give you just a second to think about that. Let's go ahead and run think about that. Let's go ahead and run think about that. Let's go ahead and run this. this. this. Well, they're both five. Why is that? Well, they're both five. Why is that? Well, they're both five. Why is that? Remember, they're both pointing to the Remember, they're both pointing to the Remember, they're both pointing to the same location in memory. So, when I same location in memory. So, when I same location in memory. So, when I changed counter two, I'm changing changed counter two, I'm changing changed counter two, I'm changing counter one. They're pointing to the counter one. They're pointing to the counter one. They're pointing to the same memory location. same memory location. same memory location. Okay, that should be pretty standard Okay, that should be pretty standard Okay, that should be pretty standard object-oriented programming work in C object-oriented programming work in C object-oriented programming work in C for you. You should understand how that for you. You should understand how that for you. You should understand how that works with classes. If not, uh the C# works with classes. If not, uh the C# works with classes. If not, uh the C# magic course is a great place to start. magic course is a great place to start. magic course is a great place to start. Covers all this and more. Uh but the the Covers all this and more. Uh but the the Covers all this and more. Uh but the the way this works is they're both pointing way this works is they're both pointing way this works is they're both pointing to the same location in memory. But to the same location in memory. But to the same location in memory. But remember I said we want to talk about remember I said we want to talk about remember I said we want to talk about strrus because strrus look like classes strrus because strrus look like classes strrus because strrus look like classes but they're actually value types not but they're actually value types not but they're actually value types not reference types which means when you reference types which means when you reference types which means when you copy a strruct you actually create a copy a strruct you actually create a copy a strruct you actually create a physical copy of the data inside of it.
-
physical copy of the data inside of it. physical copy of the data inside of it. You don't just copy the reference You don't just copy the reference You don't just copy the reference location. location. location. So if I come down here and change from So if I come down here and change from So if I come down here and change from class to strruct that's all I'm doing. I class to strruct that's all I'm doing. I class to strruct that's all I'm doing. I just change from class to a strruct. You just change from class to a strruct. You just change from class to a strruct. You can still have an interface. can still have an interface. can still have an interface. None of my code seems to have changed. None of my code seems to have changed. None of my code seems to have changed. In fact, it didn't. Except for the fact In fact, it didn't. Except for the fact In fact, it didn't. Except for the fact that counter is now a strruct instead of that counter is now a strruct instead of that counter is now a strruct instead of a class. So, I'm gonna ask you again. a class. So, I'm gonna ask you again. a class. So, I'm gonna ask you again. What do you think counter one, counter What do you think counter one, counter What do you think counter one, counter 2's values are going to be? 2's values are going to be? 2's values are going to be? Think about it. Let's run it. Think about it. Let's run it. Think about it. Let's run it. Three and five. They're not the same Three and five. They're not the same Three and five. They're not the same value. Why? Because even though I took value. Why? Because even though I took value. Why? Because even though I took counter one and said put it into this counter one and said put it into this counter one and said put it into this variable which I counter should just be variable which I counter should just be variable which I counter should just be casting a different type but remember a casting a different type but remember a casting a different type but remember a strct is a value type and so it when you strct is a value type and so it when you strct is a value type and so it when you put it into an I counter variable what's put it into an I counter variable what's put it into an I counter variable what's actually doing is it's creating a copy actually doing is it's creating a copy actually doing is it's creating a copy of this it actually creates a copy on of this it actually creates a copy on of this it actually creates a copy on the heap. So now we have a a boxing the heap. So now we have a a boxing the heap. So now we have a a boxing occurring here and these two are going occurring here and these two are going occurring here and these two are going different values. They're pointing to different values. They're pointing to different values. They're pointing to different locations in memory which different locations in memory which different locations in memory which means that counter one is not connected means that counter one is not connected means that counter one is not connected to counter 2 anymore. We've create a to counter 2 anymore. We've create a to counter 2 anymore. We've create a copy by just saying put it into an copy by just saying put it into an copy by just saying put it into an interface.
-
interface. interface. So you have to understand So you have to understand So you have to understand value type versus reference type and value type versus reference type and value type versus reference type and what the differences are. Otherwise, the what the differences are. Otherwise, the what the differences are. Otherwise, the code that seemed to work just fine with code that seemed to work just fine with code that seemed to work just fine with a class and it did changes dramatically a class and it did changes dramatically a class and it did changes dramatically when you change it to a strct instead when you change it to a strct instead when you change it to a strct instead because value type and then we now have because value type and then we now have because value type and then we now have a reference type because it's an I a reference type because it's an I a reference type because it's an I counter which is an interface. counter which is an interface. counter which is an interface. So it's no longer a a value type, it's a So it's no longer a a value type, it's a So it's no longer a a value type, it's a reference type. It's on the heap now reference type. It's on the heap now reference type. It's on the heap now instead of on the stack. Okay, that's instead of on the stack. Okay, that's instead of on the stack. Okay, that's example number two. Let's comment these example number two. Let's comment these example number two. Let's comment these out as well. And we got one more and out as well. And we got one more and out as well. And we got one more and this one is going to take a bit more this one is going to take a bit more this one is going to take a bit more work to explain, but I want to help you work to explain, but I want to help you work to explain, but I want to help you understand why generics are such a big understand why generics are such a big understand why generics are such a big deal innet. And it has to do with deal innet. And it has to do with deal innet. And it has to do with boxing. So let's start off with a const boxing. So let's start off with a const boxing. So let's start off with a const int. We're going to say underscore list int. We're going to say underscore list int. We're going to say underscore list count. We're going to say equals 1 count. We're going to say equals 1 count. We're going to say equals 1 million.
-
million. million. Now, real quick, quick thing here. Um, Now, real quick, quick thing here. Um, Now, real quick, quick thing here. Um, when you have a long number like this, when you have a long number like this, when you have a long number like this, it's hard to read. How many zeros there it's hard to read. How many zeros there it's hard to read. How many zeros there is? Is it six or seven? Maybe it's just is? Is it six or seven? Maybe it's just is? Is it six or seven? Maybe it's just my eyes because I'm getting older. But my eyes because I'm getting older. But my eyes because I'm getting older. But what you can do is you can use what you can do is you can use what you can do is you can use underscores underscores underscores as if they were commas. So, if you're in as if they were commas. So, if you're in as if they were commas. So, if you're in uh Europe, I believe it's it's periods uh Europe, I believe it's it's periods uh Europe, I believe it's it's periods instead of commas. But um the the instead of commas. But um the the instead of commas. But um the the separators between the numbers. Okay. So separators between the numbers. Okay. So separators between the numbers. Okay. So this is a separator that will work that this is a separator that will work that this is a separator that will work that will be ignored by the compiler. So the will be ignored by the compiler. So the will be ignored by the compiler. So the compiler doesn't see the underscores but compiler doesn't see the underscores but compiler doesn't see the underscores but we do. And remember code is meant to be we do. And remember code is meant to be we do. And remember code is meant to be read by humans. So this allows us to read by humans. So this allows us to read by humans. So this allows us to group our numbers in a way that's much group our numbers in a way that's much group our numbers in a way that's much easier to quickly glance at and get go easier to quickly glance at and get go easier to quickly glance at and get go got it 1 million. as opposed to if we got it 1 million. as opposed to if we got it 1 million. as opposed to if we have this and we accidentally put an have this and we accidentally put an have this and we accidentally put an extra zero in there. Can you really tell extra zero in there. Can you really tell extra zero in there. Can you really tell at a glance that's 10 million? Well, at a glance that's 10 million? Well, at a glance that's 10 million? Well, maybe if your eyes are young enough, maybe if your eyes are young enough, maybe if your eyes are young enough, sure. But the reality is it's kind of sure. But the reality is it's kind of sure. But the reality is it's kind of hard to see, especially get into extra hard to see, especially get into extra hard to see, especially get into extra zeros like this. Now, you're like, how zeros like this. Now, you're like, how zeros like this. Now, you're like, how how many is that? Well, if you put your how many is that? Well, if you put your how many is that? Well, if you put your separators in the right place, you go, separators in the right place, you go, separators in the right place, you go, "Oh, it's 1 billion." Which I don't want "Oh, it's 1 billion." Which I don't want "Oh, it's 1 billion." Which I don't want 1 billion. I want 1 million. So, let's 1 billion. I want 1 million. So, let's 1 billion. I want 1 million. So, let's go there. Okay. So this is a little bit go there. Okay. So this is a little bit go there. Okay. So this is a little bit of setup work. I'm gonna say long bytes of setup work. I'm gonna say long bytes of setup work. I'm gonna say long bytes before and then long total bytes.
-
before and then long total bytes. before and then long total bytes. Okay, this is going to capture the Okay, this is going to capture the Okay, this is going to capture the garbage collection. Um the GC captures garbage collection. Um the GC captures garbage collection. Um the GC captures how many bytes of memory are are being how many bytes of memory are are being how many bytes of memory are are being allocated for our application. We're allocated for our application. We're allocated for our application. We're going to capture before and after we do going to capture before and after we do going to capture before and after we do some work. Now I do want to point out some work. Now I do want to point out some work. Now I do want to point out real quick here that because I have I'm real quick here that because I have I'm real quick here that because I have I'm not declaring values for these. I could not declaring values for these. I could not declaring values for these. I could in theory do this. Let's put a comma in theory do this. Let's put a comma in theory do this. Let's put a comma here and declare both of them in one here and declare both of them in one here and declare both of them in one line. I don't like to do that. This a line. I don't like to do that. This a line. I don't like to do that. This a little pro tip here. The reason why it little pro tip here. The reason why it little pro tip here. The reason why it is hard to skim down and see the out the is hard to skim down and see the out the is hard to skim down and see the out the definition of total bytes here because definition of total bytes here because definition of total bytes here because you're used to saying, "Oh, long byes you're used to saying, "Oh, long byes you're used to saying, "Oh, long byes before." And that's that's the before." And that's that's the before." And that's that's the definition of bytes. But where is total definition of bytes. But where is total definition of bytes. But where is total bytes? You have to keep reading over and bytes? You have to keep reading over and bytes? You have to keep reading over and it's hard to skim. So this is really it's hard to skim. So this is really it's hard to skim. So this is really clear. We have two different variable clear. We have two different variable clear. We have two different variable definitions here. Long and long bytes definitions here. Long and long bytes definitions here. Long and long bytes before and total bytes. That just makes before and total bytes. That just makes before and total bytes. That just makes it easier to read. And again, code is it easier to read. And again, code is it easier to read. And again, code is meant to be read by humans. Okay, we're meant to be read by humans. Okay, we're meant to be read by humans. Okay, we're going to create two different uh sets of going to create two different uh sets of going to create two different uh sets of data. We're first create a list of type data. We're first create a list of type data. We're first create a list of type int. This is generic list. We're call int. This is generic list. We're call int. This is generic list. We're call list one. We're going to say equals new.
-
list one. We're going to say equals new. list one. We're going to say equals new. And I don't know if you know this or And I don't know if you know this or And I don't know if you know this or not, but a list still has an array not, but a list still has an array not, but a list still has an array behind it. and it gets declared with a behind it. and it gets declared with a behind it. and it gets declared with a certain number if you if you default it certain number if you if you default it certain number if you if you default it there's a certain number of elements get there's a certain number of elements get there's a certain number of elements get created with and then once you get near created with and then once you get near created with and then once you get near that it reallocates for a larger list that it reallocates for a larger list that it reallocates for a larger list [snorts] but you can if you know the [snorts] but you can if you know the [snorts] but you can if you know the number of elements you don't want your number of elements you don't want your number of elements you don't want your your list your generic list you can just your list your generic list you can just your list your generic list you can just pass that in so I'm passing in the 1 pass that in so I'm passing in the 1 pass that in so I'm passing in the 1 million elements and then I'm going to million elements and then I'm going to million elements and then I'm going to create an array list this is something create an array list this is something create an array list this is something that we don't use as much anymore for a that we don't use as much anymore for a that we don't use as much anymore for a good reason we're going to see why good reason we're going to see why good reason we're going to see why And it declares the same way new or And it declares the same way new or And it declares the same way new or again say list count. again say list count. again say list count. So this is a generic list of type int So this is a generic list of type int So this is a generic list of type int and this is a non-generic and this is a non-generic and this is a non-generic array list. array list. array list. Now I'm going to do a for each or I'm Now I'm going to do a for each or I'm Now I'm going to do a for each or I'm sorry a for loop. I'm going to say for sorry a for loop. I'm going to say for sorry a for loop. I'm going to say for uh i is less than list count. And then uh i is less than list count. And then uh i is less than list count. And then in here we're going to say list one.add in here we're going to say list one.add in here we're going to say list one.add add add add and just add the i. So essentially our and just add the i. So essentially our and just add the i. So essentially our list list one is going to contain from 0 list list one is going to contain from 0 list list one is going to contain from 0 to 999999.
-
to 999999. to 999999. So a whole bunch of of integers in it. So a whole bunch of of integers in it. So a whole bunch of of integers in it. Again, obviously this is for demo Again, obviously this is for demo Again, obviously this is for demo purposes. But I want to know how much purposes. But I want to know how much purposes. But I want to know how much pressure does this put on our memory? pressure does this put on our memory? pressure does this put on our memory? How much memory allocation is being How much memory allocation is being How much memory allocation is being done? Well, we can figure that out by done? Well, we can figure that out by done? Well, we can figure that out by saying be or bytes before saying be or bytes before saying be or bytes before equals GC for garbage collection equals GC for garbage collection equals GC for garbage collection collection um get allocated bytes for collection um get allocated bytes for collection um get allocated bytes for current thread. Now what this is doing current thread. Now what this is doing current thread. Now what this is doing is getting the currently allocated bytes is getting the currently allocated bytes is getting the currently allocated bytes of our thread before we do this work. of our thread before we do this work. of our thread before we do this work. And then what we'll do is down below And then what we'll do is down below And then what we'll do is down below we'll say total bytes equals GC we'll say total bytes equals GC we'll say total bytes equals GC get allocated bytes for current thread get allocated bytes for current thread get allocated bytes for current thread minus bytes before. So what that does is minus bytes before. So what that does is minus bytes before. So what that does is it gives us our difference. So now our it gives us our difference. So now our it gives us our difference. So now our total bytes is just what this allocated. total bytes is just what this allocated. total bytes is just what this allocated. That's it. Not what this allocated, not That's it. Not what this allocated, not That's it. Not what this allocated, not anything else. Just what this task anything else. Just what this task anything else. Just what this task allocated.
-
allocated. allocated. Okay. Now I'm going to say console right Okay. Now I'm going to say console right Okay. Now I'm going to say console right line and we're going to say string line and we're going to say string line and we're going to say string interpolation interpolation interpolation and say list of type int and then we're and say list of type int and then we're and say list of type int and then we're going to say total bytes and give it 10 going to say total bytes and give it 10 going to say total bytes and give it 10 places. That way it lines up well uh places. That way it lines up well uh places. That way it lines up well uh with the other element and we're going with the other element and we're going with the other element and we're going to say uh z n0 zero at the end for no to say uh z n0 zero at the end for no to say uh z n0 zero at the end for no decimal points uh bytes allocated. decimal points uh bytes allocated. decimal points uh bytes allocated. Okay, so this is going to tell us how Okay, so this is going to tell us how Okay, so this is going to tell us how much memory was allocated but just for much memory was allocated but just for much memory was allocated but just for this. Let's copy this whole thing here this. Let's copy this whole thing here this. Let's copy this whole thing here and paste it again. So copy and paste. and paste it again. So copy and paste. and paste it again. So copy and paste. We're doing the same exact thing except We're doing the same exact thing except We're doing the same exact thing except change to list two instead of list one. change to list two instead of list one. change to list two instead of list one. So we're adding the same values to list So we're adding the same values to list So we're adding the same values to list two as list one. And come down here. um two as list one. And come down here. um two as list one. And come down here. um we're going to change this to um array we're going to change this to um array we're going to change this to um array list instead of list of type int. Okay, so instead of list of type int. Okay, so that's all we're doing different is that's all we're doing different is that's all we're doing different is adding the same elements to list two and adding the same elements to list two and adding the same elements to list two and we're capturing that same um total we're capturing that same um total we're capturing that same um total bytes.
-
bytes. bytes. Now I want to take a minute and just Now I want to take a minute and just Now I want to take a minute and just just think in your mind kind of just think in your mind kind of just think in your mind kind of visualize how many bytes do you think a visualize how many bytes do you think a visualize how many bytes do you think a million allocations is going to cost us million allocations is going to cost us million allocations is going to cost us for list of type int and then how many for list of type int and then how many for list of type int and then how many bytes do you think it's going to cost us bytes do you think it's going to cost us bytes do you think it's going to cost us for array list. It's not the initial for array list. It's not the initial for array list. It's not the initial allocation. It's just the actual adding allocation. It's just the actual adding allocation. It's just the actual adding to our lists. to our lists. to our lists. Let's see. Let's see. Let's see. Well, zero bytes for a list of type int Well, zero bytes for a list of type int Well, zero bytes for a list of type int and 24 million bytes for array list. and 24 million bytes for array list. and 24 million bytes for array list. Why? Well, because let's start with zero Why? Well, because let's start with zero Why? Well, because let's start with zero bytes. The reason why we already bytes. The reason why we already bytes. The reason why we already allocated spots for a million integers. allocated spots for a million integers. allocated spots for a million integers. So, we already have that allocation So, we already have that allocation So, we already have that allocation done. It did cost something. We'll see done. It did cost something. We'll see done. It did cost something. We'll see that in just a minute. But now we've got that in just a minute. But now we've got that in just a minute. But now we've got the allocation done. It costs us no more the allocation done. It costs us no more the allocation done. It costs us no more to put the values into our list. But to put the values into our list. But to put the values into our list. But with our array list, well, it's got to with our array list, well, it's got to with our array list, well, it's got to box every single integer, which again box every single integer, which again box every single integer, which again remember means create the pointer in remember means create the pointer in remember means create the pointer in memory. That's actually some storage memory. That's actually some storage memory. That's actually some storage there. And then it's going to point to there. And then it's going to point to there. And then it's going to point to that box with the integer inside, which that box with the integer inside, which that box with the integer inside, which is more memory on the heap. So the total is more memory on the heap. So the total is more memory on the heap. So the total is 24 million bytes allocated for our is 24 million bytes allocated for our is 24 million bytes allocated for our array list. Now obviously if you were array list. Now obviously if you were array list. Now obviously if you were doing five instead of a million that doing five instead of a million that doing five instead of a million that would be a lot less and the difference would be a lot less and the difference would be a lot less and the difference would be negligible but I want to point would be negligible but I want to point would be negligible but I want to point out there is a radical difference. Now,
-
out there is a radical difference. Now, out there is a radical difference. Now, let's cut this out of here and move it let's cut this out of here and move it let's cut this out of here and move it down be so that we're capturing how much down be so that we're capturing how much down be so that we're capturing how much it actually costs to allocate as well. it actually costs to allocate as well. it actually costs to allocate as well. Just so we're being honest about the Just so we're being honest about the Just so we're being honest about the fact that you know what the costs fact that you know what the costs fact that you know what the costs actually are. So now we're capturing the actually are. So now we're capturing the actually are. So now we're capturing the allocation as well as the assignment, allocation as well as the assignment, allocation as well as the assignment, not just the assignment. Let's run it not just the assignment. Let's run it not just the assignment. Let's run it again. As you can see, list of type int again. As you can see, list of type int again. As you can see, list of type int now has a cost. It's 4 million bytes. 4 now has a cost. It's 4 million bytes. 4 now has a cost. It's 4 million bytes. 4 million 56 bytes of allocation. But our million 56 bytes of allocation. But our million 56 bytes of allocation. But our array list is 32 million bytes well 32 array list is 32 million bytes well 32 array list is 32 million bytes well 32 million56 bytes of allocation. Which million56 bytes of allocation. Which million56 bytes of allocation. Which means that not only do we have our 24 means that not only do we have our 24 means that not only do we have our 24 million hidden in here, but we also have million hidden in here, but we also have million hidden in here, but we also have an additional 4 million on top of that an additional 4 million on top of that an additional 4 million on top of that beyond what list of type int uses. So we beyond what list of type int uses. So we beyond what list of type int uses. So we have a lot more memory allocations even have a lot more memory allocations even have a lot more memory allocations even we're taking in the initial allocation we're taking in the initial allocation we're taking in the initial allocation of the list itself. So when we're of the list itself. So when we're of the list itself. So when we're talking about boxing and unboxing they talking about boxing and unboxing they talking about boxing and unboxing they get very expensive because this right get very expensive because this right get very expensive because this right now we've just boxed those elements. We now we've just boxed those elements. We now we've just boxed those elements. We have not unboxed them which we'll have have not unboxed them which we'll have have not unboxed them which we'll have to do if we want to use those integers.
-
to do if we want to use those integers. to do if we want to use those integers. And here we don't have to do boxing or And here we don't have to do boxing or And here we don't have to do boxing or unboxing. Why? Well, because when you unboxing. Why? Well, because when you unboxing. Why? Well, because when you have a list, let's move this back. They have a list, let's move this back. They have a list, let's move this back. They were by the way. Um, I like to have them were by the way. Um, I like to have them were by the way. Um, I like to have them all key up top. U, but I did want you to all key up top. U, but I did want you to all key up top. U, but I did want you to see the the cost differences. So, why is see the the cost differences. So, why is see the the cost differences. So, why is this so cheap? Well, because what's this so cheap? Well, because what's this so cheap? Well, because what's happening here is a list of type T, happening here is a list of type T, happening here is a list of type T, which is what we're using here. Um, what which is what we're using here. Um, what which is what we're using here. Um, what that does is it says, I'm going to that does is it says, I'm going to that does is it says, I'm going to figure out what type to use, and that's figure out what type to use, and that's figure out what type to use, and that's the type we're going to store. So we're the type we're going to store. So we're the type we're going to store. So we're storing the type integer. If I create a storing the type integer. If I create a storing the type integer. If I create a different list of T, I said list of different list of T, I said list of different list of T, I said list of double and let's call list three. double and let's call list three. double and let's call list three. Well, now I'm creating a list of type Well, now I'm creating a list of type Well, now I'm creating a list of type double. I'd put doubles in here instead double. I'd put doubles in here instead double. I'd put doubles in here instead of integers. So it's strongly typed for of integers. So it's strongly typed for of integers. So it's strongly typed for the correct type, which means there the correct type, which means there the correct type, which means there doesn't have to be any boxing and doesn't have to be any boxing and doesn't have to be any boxing and unboxing. unboxing. unboxing. Whereas in our array list, there's no Whereas in our array list, there's no Whereas in our array list, there's no type here, which means it's getting type here, which means it's getting type here, which means it's getting stored as an object, which means it's stored as an object, which means it's stored as an object, which means it's getting put into the box. Every single getting put into the box. Every single getting put into the box. Every single element, it's not one big box with element, it's not one big box with element, it's not one big box with multiple elements inside. No, it is one multiple elements inside. No, it is one multiple elements inside. No, it is one box per element, box per element, box per element, which means you have in this case 1 which means you have in this case 1 which means you have in this case 1 million boxes that you're creating and million boxes that you're creating and million boxes that you're creating and then putting something into and then then putting something into and then then putting something into and then create a pointer that points to that create a pointer that points to that create a pointer that points to that each box. That's a lot of allocations.
-
each box. That's a lot of allocations. each box. That's a lot of allocations. That's a lot of pressure on your garbage That's a lot of pressure on your garbage That's a lot of pressure on your garbage collector. That's a lot of pressure on collector. That's a lot of pressure on collector. That's a lot of pressure on your memory. So this is why it's really your memory. So this is why it's really your memory. So this is why it's really important important important that that you actually understand what's that that you actually understand what's that that you actually understand what's going on under the hood because if you going on under the hood because if you going on under the hood because if you just say oh this works like this right just say oh this works like this right just say oh this works like this right on here this works so therefore it must on here this works so therefore it must on here this works so therefore it must be right it must be just a different be right it must be just a different be right it must be just a different option that Microsoft provides. know option that Microsoft provides. know option that Microsoft provides. know there is a reason why we do one over the there is a reason why we do one over the there is a reason why we do one over the other and part of it is knowing when to other and part of it is knowing when to other and part of it is knowing when to use each because there may be a time to use each because there may be a time to use each because there may be a time to use array list but this wouldn't be the use array list but this wouldn't be the use array list but this wouldn't be the time. So knowing when to use each is time. So knowing when to use each is time. So knowing when to use each is rather important. rather important. rather important. This is also why when you go for an This is also why when you go for an This is also why when you go for an interview you're talking to the interview you're talking to the interview you're talking to the interviewer and they're a technical interviewer and they're a technical interviewer and they're a technical person. They may ask you questions like person. They may ask you questions like person. They may ask you questions like stack and heap and garbage collection stack and heap and garbage collection stack and heap and garbage collection and boxing and other things. It's not and boxing and other things. It's not and boxing and other things. It's not just to be pedantic. Now, sometimes it just to be pedantic. Now, sometimes it just to be pedantic. Now, sometimes it is. Sometimes they're just trying to, is. Sometimes they're just trying to, is. Sometimes they're just trying to, you know, use fancy words and hope that, you know, use fancy words and hope that, you know, use fancy words and hope that, you know, only certain people know them.
-
you know, only certain people know them. you know, only certain people know them. But the reality is it's important that But the reality is it's important that But the reality is it's important that you know these things because your code you know these things because your code you know these things because your code may work, but it may not work well. It may work, but it may not work well. It may work, but it may not work well. It may look like things are okay, but the may look like things are okay, but the may look like things are okay, but the reality is that once you get hundreds reality is that once you get hundreds reality is that once you get hundreds and thousands of users starting to use and thousands of users starting to use and thousands of users starting to use your application, it's going to slow to your application, it's going to slow to your application, it's going to slow to a crawl. It's going to fill up your a crawl. It's going to fill up your a crawl. It's going to fill up your entire memory. It's going to cause the entire memory. It's going to cause the entire memory. It's going to cause the garbage collection system to work garbage collection system to work garbage collection system to work overtime to try and clean things up overtime to try and clean things up overtime to try and clean things up after yourself because of the fact that after yourself because of the fact that after yourself because of the fact that you're allocating more things than you you're allocating more things than you you're allocating more things than you need to. So, it's important that you need to. So, it's important that you need to. So, it's important that you understand what's going on under the understand what's going on under the understand what's going on under the hood and not just assume that well the hood and not just assume that well the hood and not just assume that well the AI built it right or well this works AI built it right or well this works AI built it right or well this works therefore it's it's right. You need to therefore it's it's right. You need to therefore it's it's right. You need to understand the why behind what we understand the why behind what we understand the why behind what we choose. Otherwise, you'll make some bad choose. Otherwise, you'll make some bad choose. Otherwise, you'll make some bad decisions and cause your application to decisions and cause your application to decisions and cause your application to be slower than it needs to be, take up be slower than it needs to be, take up be slower than it needs to be, take up more memory it needs to take up, or just more memory it needs to take up, or just more memory it needs to take up, or just cause more problems. Okay, so that's how cause more problems. Okay, so that's how cause more problems. Okay, so that's how boxing works. That's there's a lot more boxing works. That's there's a lot more boxing works. That's there's a lot more you could probably cover in this.
-
you could probably cover in this. you could probably cover in this. There's other things, but I want to There's other things, but I want to There's other things, but I want to cover kind of the big things with boxing cover kind of the big things with boxing cover kind of the big things with boxing um to really understand how um the the um to really understand how um the the um to really understand how um the the practicality of stack versus heap and practicality of stack versus heap and practicality of stack versus heap and and moving things from the stack to the and moving things from the stack to the and moving things from the stack to the heap, etc. So you understand what's heap, etc. So you understand what's heap, etc. So you understand what's going on under the hood and so you going on under the hood and so you going on under the hood and so you understand how to make your applications understand how to make your applications understand how to make your applications more efficient. Thanks for watching and more efficient. Thanks for watching and more efficient. Thanks for watching and as always, I am Tim Corey.
No summary available yet.
View original episode ↗