Reference Types in C#
C# reference types hold references to objects, so two variables can point to the same instance and observe the same changes.
Transcript 1 topic
Reference types in C#
0:00So what is a reference type in C Sharp? Well, objects are types that are passed by reference. What does that mean? Well, basically you're not passing the object, you're passing a reference to the object likely in memory. Well, let's talk about what that means in the real world.
Let's say you have a bald bearded builder named b b b. But let's say you wanna make another one like you would encode with var person two equals person one. Now that you want another bald bearded builder, you wanna call it Mike. Well, what happens? Well, you're essentially naming it something else.
You've still only got one bald bearded builder, but you've got two objects each with a reference to that same one. So if we say, hey, we want that BBB to shave his beard. I'm not gonna do that. But if I had both the Mike bald bearded builder and the BBB bald Bearded Builder would both have no beard now. That's because they're passed by reference.
What you're actually passing around is the location of that object in memory. They're called different things, but they're pointing to the same spot. And that's the basics of reference types.
Sign in to join in. Reading needs nothing.