Back to articles

Tag archive

#boxing

D
Nov 12, 2026

Decompiling boxing, unboxing and the constrained. prefix in C#

An implicit conversion from int to object is invisible in C# but allocates on the heap — and the IL says so with a box opcode. This walks through where box, unbox.any and the constrained. prefix come from, why generic code uses constrained. to dodge a boxing allocation, and how Glass.NET reconstructs readable C# while the IL reveals the allocation that the source hides.

Nov 12, 20267 min read0 reactions0 comments