Nested loops through recursion with usable iterators
- by narandzasto
Help! I need to generate a query with loops,but there must be undefinitly numbers of loop or much as many a client wants. I know that it can be done with recursion,but don't know exectly how.One more thing. Notice,please,that I need to use those k,i,j iterators later in "if" condition and I don't know how to catch them. Thanks
class Class1
{
public void ListQuery()
{
for (int k = 0; k < listbox1.Count; k++)
{
for (int i = 0; i < listbox2.Count; i++)
{
for (int j = 0; j < listbox3.Count; j++)
{
if (k == listbox1.count-1 && i == listbox2.count-1 && j == listbox3.count-1)
{
if (!checkbox1) Query += resultset.element1 + "=" + listbox1[k];
if (!checkbox2) Query += resultset.element2 + "=" + listbox1[i];
if (!checkbox3) Query += resultset.element3 + "=" + listbox1[j];
}
}
}
}
}
}