This implements the answer to the question you link:
static string Get(string chars, int n, int i)
{
string ret = "";
int sizes = 1;
for (int j = 0; j < n; j++) {
ret = chars[(i / sizes) % chars.Length] + ret;
sizes *= chars.Length;
}
return ret;
}
Example:
string chars = "abcd";
int n = 3;
for (int i = 0; i < Math.Pow(chars.Length, n); i++)
Console.WriteLine(i + "\t" + Get(chars, n, i));
0 aaa 1 aab 2 aac 3 aad ... 61 ddb 62 ddc 63 ddd