0

I'm kind of looking for a solution to this problem. Currently I have a product object. The object contains a list of attribute, inputted by a user, so I have no way to know beforehand how many attributes the user is going to enter.

Lets assume we have 2 lists:

Attribute List: Color Size

Value List:

Color: Red Blue
Size: Small Medium Large

I want to iterate through the the attribute list and value list to create every non-duplicate pair possible so that it would go like this:

[Red,Small][Red,Medium][Red,Large][Blue,Small][Blue,Medium][Blue,Large]

Using C#, I'm stuck at figuring how how to pair them using loops for dynamic list number (my implementation only counted for 2 attribute lists, what if the user input 3 or 4 list?)

  • There are actually no lists here, or C# code, you have to imagine how hard it is to debug and solve C# issues when you have given no sample code or concrete implementations or try'able examples. As such we have to make a whole bunch of assumptions to understand the nature of the problem. If you could fix a few of these issues, this question is sure to be answered quickly... or it could be just me – TheGeneral Jul 24 '20 at 04:16
  • Ah sorry. I was trying to ask and hoping to receive the general idea to go towards the right direction to solve the problem, which is why I just provided sample instead. But I shall close the issues now cause I've already found it. It falls under cross-joining sets or cartesian products. Thank you for the input though. – Mai Anh Vu Jul 24 '20 at 06:17

0 Answers0