Does C# compiler hardcode a special processing for IEnumerable?

Viewed 258

As an example use the Join() method from class String. When you call it on a byte array, e.g.

 byte[] bytes = {3,4,5};
 string str = string.Join(",", bytes);

C# compiler maps Join to this signature

 public static String Join<T>(String separator, IEnumerable<T> values);

However, byte[] derives implicitly from class Array which does not derive from the generic IEnumerable, instead it derives from the non-generic IEnumerable, i.e.

 public abstract class Array : ICloneable, IList, ICollection, IEnumerable, IStructuralComparable, IStructuralEquatable {...}

If I do the same with my own interfaces and class that resemble this case, I will get a compiler error as expected because according to the rules you cannot cast a class deriving from an interface IA (non-generic IEnumerable) into an interface IB (generic IEnumerable) that derives from IA. This means that C# compiler simply hardcodes the specific name IEnumerable. Where is this explained?

2 Answers
Related