Practice · 2 of 2
Struct reinterpretation
CHALLENGE
Difficulty: advanced+25 XP
Implement struct Packet { public uint Header; public uint Payload; } and static uint[] ReadPacketBytes(byte[] bytes) that reinterprets an 8-byte segment as a Packet via MemoryMarshal.Read<Packet> — returning [Header, Payload] as a uint array. The test feeds little-endian bytes and verifies field values; the lesson: reinterpretation is layout-dependent and never a substitute for a real parser.
Press Submit to check your solution.
Back to lesson: Practice: Unsafe drills