Just to extend Jon's answer just a little bit, boxing will also occur, when you call non-overridden or non-virtual methods of the base class also, like
i.GetType(); //boxing occur here
or pass int
to a method, which requires a reference type
void Foo(object obj) {}
Foo(i); //boxing, no overload takes an int
In the first example IL
you can clearly see box
instruction
int i = 5;
i.GetType();
IL_0000: ldc.i4.5
IL_0001: stloc.0 // i
IL_0002: ldloc.0 // i
IL_0003: box System.Int32 //<---- boxing
IL_0008: call System.Object.GetType
If you don't override virtual methods in your value types, they will also be boxed when calling them
enum MyEnum {}
var e = new MyEnum();
e.ToString(); //box will occur here, see IL for details
IL_0000: ldc.i4.0
IL_0001: stloc.0 // e
IL_0002: ldloc.0 // e
IL_0003: box UserQuery.MyEnum
IL_0008: callvirt System.Object.ToString
The same situations with structs, except they will use callvirt
opcode, that will box the struct if nessecary,