Learn the difference between reference types and value types in your programs in this video, the difference between structs and classes, and how reference types can create unexpected side effects in your code.
- [Instructor] Programmers are often used to … being in control of whether the values they assign … to variables are simply values or are … references to existing objects. … However, in C# the decision is made … by the programmer who defined the object, … not by the programmer who instantiates the object … and assigns it to a variable. … This is a common pitfall for those new to C#. … Let's take a look at an example. … If you're not sure whether the object you are using … is a value or a reference type, … you could run in to some errors. … Lets take a look at this example. … In this program we have a class called Person … and each person has a string name … which is initialized with the person constructor. … Inside of the person class we also have … a fictional character struct, … where each fictional character has a fictional name … and we assign that in the constructor. … Lets run this code and see what happens. … So here we get … Rebecca, Rebecca, Harry Potter, Hermione Granger … what does all that mean? …
- Debugging defined
- Working with breakpoints
- Inspecting values of variables
- Defensive programming
- Common C# errors
- Debugging challenges