CSharp - Interfaces and Boxing


Converting a struct to an interface causes boxing.

Calling an implicitly implemented member on a struct does not cause boxing:

interface  Printable {
   void Test();
struct PDFDocument : Printable {
   public void Test() {}

PDFDocument s = new PDFDocument();
s.Test();            // No boxing.
Printable i = s;     // Box occurs when casting to interface.