Bald Bearded Builder
csharp/value-types-in-csharp

Value Types in C#

Using `var` can reduce repetition and simplify refactoring, but descriptive names and team-wide consistency matter more than personal preference.

Loads from YouTube when you press play

Transcript 1 topic

Value types copy data

0:00

Hey, Mike. How do value types work in C? Well, let's talk about it. Value types are passed by value, which means you're actually passing a copy of the object around. What does that mean in the real world?

Let's say you have a Bulb Bearded Builder named BBB and you come along later and you say, hey, I want another Bald Bearded Builder, but I wanna name it Mike. That would be like your code saying var person two equals person one. What happens? Now you've got another Bald Bearded Builder named Mike. They're two different objects because they were passed by value.

That means if I say bald bearded builder Mike, I want you to have hair. Well, then he gets hair. But notice that the BBB bald bearded builder doesn't have hair. They're two separate objects because they were passed by value. And that's a very simplistic way to explain value types in C sharp.

Sign in to join in. Reading needs nothing.