Reputation: 378
How do I cast a IEnumerable<IEnumerable<T>>
to a string[][]
or a List<string[]>
?
I already tried .toArray
and .SelectMany
but they seem to create either string[]
or List<IEnumerable<string>>
which is not what I really want.
Upvotes: 2
Views: 305
Reputation: 1208
You could use Select
to map each inner IEnumerable<string>
to a string[]
:
string[][] arrayOfStringArrays = enumerable.Select(innerEnumerable => innerEnumerable.ToArray()).ToArray();
Upvotes: 5