Sitemap

Member-only story

The Heap Is Not the Stack

What actually happens when C# creates values, objects, references, and local variables

10 min readOct 4, 2026

--

Press enter or click to view image in full size
Photo by Miguel Saddi Vitorino

One of the first explanations that took me beneath the surface of C# looked something like this.

STACK                         HEAP
int age = 42                  Person object
bool active = true List object
reference to customer --> Customer object

It’s wonderfully easy to remember, and tremendously useful, because it introduces a distinction that C# syntax can make surprisingly easy to miss.
It comes down to understanding that a variable can hold the thing itself, or it can hold a way to get to the thing.

Imagine we are building a game. Somewhere in that game is a player called Ada. She has 100 health points and a sword.

player1 ─────┐
│
▼
PLAYER OBJECT
┌───────────────┐
│ Name: Ada │
│ Health: 100 │
│ Weapon: Sword │
└───────────────┘

The variable player1 is not Ada. It contains a reference that lets our code reach Ada's Player object.

Now we do this.

Player player2 = player1;

--

--

coding | seaphylla | omnivorous
coding | seaphylla | omnivorous

Written by coding | seaphylla | omnivorous

I write about coding, AI, philosophy of mind, and logic with intellectually omnivorous curiosity. Founder of OnlyFangirling.com. The joke is, I only fangirl.