I have two lists, one for the items and the other for its values, how can i print the contents like this Example:
Items List -> [1], [2]
valuesList1 -> a, b
valuesList2 -> c, d
Desired Output:
case 1: 1-a 2-c
case 2: 1-a 2-d
case 3: 1-b 2-c
case 4: 1-b 2-d
My code:
foreach (var item in listItem)
{
foreach (var itemValue in item.listItemValue)
{
text += item.value + " - " + itemValue.value + "\n";
}
text += "\n";
}
MessageBox.Show(text);
Output:
1 - a
1 - b
2 - c
2 - d
EDIT
Desired output:
case 1: 1-a 2-c
case 2: 1-a 2-d
case 3: 1-b 2-c
case 4: 1-b 2-d
My code and output:
int n = 0;
var produtoCartesiano = itens.SelectMany(x => valoresItens.Select(y => x + y));
foreach (var caso in produtoCartesiano)
{
result += "case " + n + ": ";
result += caso;
result += "\n";
n++;
}
MessageBox.Show(result);
Output:
case 0: 1a
case 1: 1b
case 2: 1c
case 3: 1d
case 4: 2a
case 5: 2b
case 6: 2c
case 7: 2d
What else do I need to add in my code to generate the desired output?