Chapter 4: Classes and Linked Lists
Arrays gave us our first reference type. In this chapter, we define our own. Classes let us create objects that bundle data with behavior, control what outside code can access, and model structures that are linked together through references.
Linked lists are the main case study. They give us a concrete reason to care about constructors, methods, private fields, traversal with references, higher-order methods, and finally generics.
Chapter Sections
- Data and Memory: How C# represents classes and how we can use them to define Linked Lists.
- Basic Computation: How methods and properties give class objects behavior and controlled access.
- Problem Solving with Linked Lists: How to traverse, search, and modify linked lists through a class interface.
- Higher-Order Methods: How linked-list methods become more reusable when functions are passed in.
- Generics: How one linked-list implementation can work for many different element types.
We begin with Section 1 - Data and Memory: how classes differ from structs and arrays in memory.