I want to list all possible combinations that result from selecting at-least one and atmost all elements from each set out of a number(unknown) of sets input by user. An element may be in more than one set but listing it more than once is not a problem.
Eg:- If the user enters 3 sets as
{1,3,5}
{2,4}
{1}
Output
1,2,1
1,4,1
1,2,4,1
3,2,1
3,4,1
3,2,4,1
5,2,1
5,4,1
5,2,4,1
1,3,2,1
1,3,4,1
1,3,2,4,1
1,5,2,1
1,5,4,1
1,5,2,4,1
3,5,2,1
3,5,4,1
3,5,2,4,1
1,3,5,2,1
1,3,5,4,1
1,3,5,2,4,1
C# code will be even more helpful. Thanks.