Original Post
Halo, I am having a big problem with arraylist/array item combinations. This is not a home work question. I need it very urgent and I tried out some method which is not useful. The problem is that I have a array as follows: Array = {"A", "Sd", Fg", "X", ....may contain n items} How to find out the possible combination between these items? The expected answer would be ASdFgX, XSdFgA, SdXAFg, etc. I tried out so many methods. But being a beginner in C#, it is hard to find out. Please help me. I am using C#.Net2 Win Apps. I tried out following method using an array list....... ArrayList list = new ArrayList(); list.Add("A"); list.Add("Sd"); list.Add("Fg"); list.Add("X"); int count = 0; for (int i = 0; i < list.Count; i++) { lst1.Items.Add(list.ToString()); for (int j = 0; j < list.Count; j++) { if (j != i) lst1.Items.Add(list.ToString() + list[j].ToString()); for (int k = 0; k < list.Count; k++) { if ((k != i) && (k != j) && (j != i)) lst1.Items.Add(list.ToString() + list[j].ToString() + list[k].ToString()); for (int l = 0; l < list.Count; l++) { if ((k != i) && (k != j) && (j != i) && (l != k) && (l != j) && (l != i)) { lst1.Items.Add(list.ToString() + list[j].ToString() + list[k].ToString() + list[l].ToString()); } } } } } (Here lst1 is the ListBox) This is good for if we have 3 or 4 items in the array. But what to do if there is more than 10 items in the array?? pls help me. Thanks in advance