Skip to Content
Learn
Reference Fundamentals
References vs. Values II

While reference-type variables refer to a place in memory, value-type variables hold the actual data.

Let’s put that into practice with a little code.

Instructions

1.

Create a Book variable bookLocation that refers to a new Book object.

The variable is a reference to the object’s location in memory.

2.

Create another Book variable named sameBookLocation and set it equal to bookLocation.

Both variables refer to the same location in memory.

3.

Create a bool variable falseValue that refers to the boolean value false.

The variable holds the actual value.

4.

Create another bool variable anotherFalseValue and set it equal to falseValue.

The false value was copied to a new location in memory for anotherFalseValue to use.

Folder Icon

Take this course for free

Already have an account?