This problem emerged as a discussion in the comments of this question. Feel free to seek more context if you wish.
Let's say we have the following three variables:
Dim stringArray = {"foo", "bar"}
Dim jaggedArray = {stringArray}
Dim nestedIEnumerable = jaggedArray.Select(Function(arr) arr.Select(Function(s) s))
We can easily concatenate two instances of nestedIEnumerable:
Dim concatenated = nestedIEnumerable.Concat(nestedIEnumerable)
But when trying to call Concat() on the jagged array:
Dim concatenated = jaggedArray.Concat(nestedIEnumerable)
..it does not compile and complains about the following:
'IEnumerable(Of IEnumerable(Of String))' cannot be converted to 'IEnumerable(Of String())' because 'IEnumerable(Of String)' is not derived from 'String()', as required for the 'Out' generic parameter 'T' in 'Interface IEnumerable(Of Out T)'.
Now, this is weird because String()() can be implicitly converted to IEnumerable(Of IEnumerable(Of String)):
Dim casted As IEnumerable(Of IEnumerable(Of String)) = jaggedArray
Dim concatenated = casted.Concat(nestedIEnumerable)
This also works just fine:
Dim concatenated = {stringArray.AsEnumerable}.Concat(nestedIEnumerable)
Why does the first one fail although there's an implicit conversion between the two types?
Note: The C# version of the first code works without a problem:
var stringArray = new[] { "foo", "bar" };
var jaggedArray = new[] { stringArray };
var nestedIEnumerable = jaggedArray.Select((arr) => arr.Select((s) => s));
var concatenated = jaggedArray.Concat(nestedIEnumerable);