Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardC#boxing and unboxing costSingle-choice MCQ

Calling an interface method on a struct value can sometimes box and sometimes not. For the two calls below, which boxes?

int x = 5; IComparable c = x; // call A c.CompareTo(0); static int Cmp<T>(T a, T b) where T : IComparable<T> => a.CompareTo(b); // call B, T = int