This is a standard interface conversion; as a requirement, arrays (T[]
) implement IEnumerable
and IEnumerable<T>
. So a string[]
is 100% compatible with IEnumerable<T>
. The implementation is provided by the compiler (arrays were basically generic before .NET generics existed).
From the spec (ECMA 334 v4) - this is a consequence of 13.1.4:
- From a one-dimensional array-type
S[]
to System.Collections.Generic.IList<S>
and base
interfaces of this interface.
- From a one-dimensional array-type
S[]
to System.Collections.Generic.IList<T>
and base interfaces of this interface, provided there is an implicit reference conversion from S
to T
.
And recall that IList<T> : IEnumerable<T>