Say I have a data structure of IEnumerable
like this:
{
{ A, B }
{ 1, 2, 3 }
{ Z }
}
You could use CartesianProduct
method by Eric Lippert for this (taken from here):
static IEnumerable> CartesianProduct(
this IEnumerable> sequences)
{
IEnumerable> emptyProduct = new[] { Enumerable.Empty() };
return sequences.Aggregate(
emptyProduct,
(accumulator, sequence) =>
from accseq in accumulator
from item in sequence
select accseq.Concat(new[] {item}));
}