Portable language tutorial
This tutorial is for developers who can read a simple C struct but have not had to calculate binary field positions by hand. You need basic C# syntax and the ideas from Binary layout basics. You do not need assembly language, compiler implementation knowledge, or native-memory programming.
The lessons use exact byte arrays and C# examples from the documentation runner:
- Your first fixed layout maps a six-byte header, explains little-endian order, and performs a
StructValueand typed read. - Composites and overlapping storage adds an enum, a fixed text field, and a union.
- Runtime data and safe traversal supplies an array count, selects one element, follows a stored pointer, and sets resource limits.
Read them in order. Each lesson answers four questions:
- Which bytes does this field own?
- What C# value does reading return?
- What must the application supply?
- Which mistake would produce a different offset or unsafe amount of work?
After the lessons, use the cookbook to adapt a tested pattern or the primitive, layout, and operation pages as lookup references.