i am looking for code that can generate an array where the first item is A, then B, then C . . .after Z i
Great answer of Vlad.
Here's another variation on that:
static IEnumerable generate() {
for (char c = 'A'; c <= 'Z'; c++) {
yield return c.ToString();
}
foreach (string s in generate()) {
for (char c = 'A'; c <= 'Z'; c++) {
yield return s + c;
}
}
}
If you don't mind starting the sequence with an empty string you could write it as follows:
static IEnumerable generate() {
yield return "";
foreach (string s in generate()) {
for (char c = 'A'; c <= 'Z'; c++) {
yield return s + c;
}
}
}