No, the above code does no boxing.
If you'd used IDictionary<int, byte>
as the argument (or IEnumerable<KeyValuePair<int, byte>>
), the enumerator itself would get boxed, since the dictionary class, like many collections, have a struct
enumerator (to save an object allocation every time you call foreach
).
In the code above, the compiler would call the dictionary's GetEnumerator
method, rather than the (implicitly implemented) IEnumerable<T>
method.