I want to have a convenience wrapper B that inherits from A<c
The difference is the following:
foreach
actually looks for a public method called GetEnumerator
. It doesn't really care for IEnumerable
. Your class B
only has one public method named GetEnumerator
: The one defined in B
which hides the one defined in A
.
ToArray
on the other hand is an extension method on IEnumerable
. As your class is both IEnumerable
and IEnumerable
the call is ambiguous between the two generic arguments string
and char[]
.