Question Best way to move through the alphabet

Monarch1st

New member
Joined
Mar 24, 2017
Messages
4
Programming Experience
10+
Hi all, newbie here. I'm brand new to c# and to vs, although I'm taking a class to introduce me, using vs2015 community. I've been using other languages for quite a while, but very limited time with c, and none with c#. Also a basic familiarity with object oriented languages, but no experience. So you're probably going to need to be fairly detailed in your answer, which I apologize for, but I gotta get up the learning curve some way.

Along with the class assignments, I'm writing my own small program (it's to assist a favorite game, but that's pretty irrelevent.)
It needs to sequentially cycle through the alphabet. It will write to a file sets of entries, with the header for each entry having a 3-letter combo: 'Aaa', 'Aab', 'Aac'...'Aaz', 'Aba'...'Abz', etc., a user-controlled number of times, but perhaps even all the way to 'Zza'...'Zzz'.
What is the best way to choose the right letter? Have an array for the alphabet? (probably one for caps, one for lowercase. easier I'd think.) A string of the alphabet, using substring to access it? Or is there an easier way?

I hope that's clear.
Thanks for the help!
 
If you specifically want three-letter combinations where the first letter is upper-case and the others are lower case then I'd suggest three nested 'for' loops. As a pointer, the outer loop might look like this:
for (var i = 'A'; i <= 'Z'; i++)
{
    // ...
}

In that loop, `i`will take the values 'A' to 'Z'. You can nest two similar loops using lower-case characters and then, inside the inner loop, combine all three characters.
 

Latest posts

Back
Top Bottom