Kartik K

Kartik K

  • 1.9k
  • 134
  • 9.1k

How to get all possible combinations ?

Dec 16 2019 3:52 AM
I have n numbers of  array contains n number of data.
I want to write out all the possible combinations.
For ex:-
var list1 = new List<string> { "A", "B", "C", "D" };
var list2 = new List<string> { "10", "20", "30", "40", "50" };
var list3 = new List<string> { "ABC", "DEF", "GHI", "JKL" };
Possible outputs :
A-10-ABC
A-10-DEF
A-10-GHI
A-10-JKL
A-20-ABC
A-20-DEF
A-20-GHI
A-20-JKL
A-30-ABC
A-30-DEF
A-30-GHI
A-30-JKL
........ and so on
The actual problem is the number of list variable is not constant, therefore I can't just write a fixed amount of nested loop.
Hope someone can help me....

Answers (2)