Hi everybody,

I have an array of letter for example:
VB Code:
  1. string strings[] = { "a", "b", "c", "d", "e"};

I want to generate all possible combinations of a specific length which is determined by the user, for example when he selects 3:

aaa
aab
aac
aad
aae
aba
abb
abc
abd
abe
abd
aca
acb
acc
acd
ace

etc...


I started by this code but it's limited to the length I assume before the runtime

VB Code:
  1. foreach (string l1 in strings)
  2.             {
  3.                 foreach (string l2 in strings)
  4.                 {
  5.                     foreach (string l3 in strings)
  6.                     {
  7.                         myword = l1 + l2 + l3;
  8.                     }
  9.                 }
  10.             }


can you think of any solution that works with any length selected by the user at runtime?

Thanks