Before you can build complex data structures, you must understand where they live. In .NET, memory is divided into two primary regions: the Stack and the Heap. Misunderstanding this is the #1 cause of performance bottlenecks and memory leaks.
The Stack is used for **Value Types** (int, bool, double) and **Reference Pointers**. It is extremely fast because it uses a Last-In-First-Out (LIFO) model. Memory is allocated and deallocated automatically as functions return. No Garbage Collection happens on the stack.
The Heap is used for **Reference Types** (Classes, Strings, Arrays). It is much larger than the stack but slower because memory must be "Found" and eventually cleaned up by the Garbage Collector (GC).
int x = 10; // Lives on the Stack
User u = new User(); // 'u' (the pointer) is on the Stack, the object is on the Heap
Q: "What is 'Boxing' and why is it an anti-pattern for high-performance code?"
Architect Answer: "Boxing is the process of converting a Value Type (Stack) into an Object (Heap). For example, `object obj = 5;`. This creates an unnecessary object on the Heap, which eventually puts pressure on the Garbage Collector. In a loop of 1 million items, boxing can slow down your app by 50x. Always use **Generics** (List