Generate all combinations for a list of strings
问题 I want to generate a list of all possible combinations of a list of strings (it's actually a list of objects, but for simplicity we'll use strings). I need this list so that I can test every possible combination in a unit test. So for example if I have a list of: var allValues = new List<string>() { "A1", "A2", "A3", "B1", "B2", "C1" } I need a List<List<string>> with all combinations like: A1 A2 A3 B1 B2 C1 A1 A2 A1 A2 A3 A1 A2 A3 B1 A1 A2 A3 B1 B2 A1 A2 A3 B1 B2 C1 A1 A3 A1 A3 B1 etc... A