That all depends on exactly what you want.
In the old ASCII days, the algorithm was easy: just add 1 to the 8 bits
that make up the character, and if it reaches, say Z, reset it to A. (I
know that .NET doesn't allow you to treat characters like integers, but
bear with me.)
In the new world of Unicode, it's not entirely clear what you mean by
"increment". For example, if you're in Germany, they have a letter that
looks like a fancy "B" that represents "ss" (I think it's called the
s-set, or something like that). Where does this occur in the sort
order? When you're incrementing through the alphabet in Germany, I
assume that this letter has to show up at some point. Where?
What about in Turkey? They have letters with accents and other glyphs
in their alphabet. Where do they fall in the sequence?
In my brief travels through .NET's globalization classes, I remember
seeing information on alphabetic sorting and sequencing, so there is
probably a way to iterate through the alphabet given a cultural
context.
My point is that if you really want to be able to iterate through the
alphabet, in any culture that happens to be set on the PC running your
program, you have to bring a lot of .NET machinery to bear in order to
do it.
Or, from the opposite point of view, if you "just want to iterate
through the alphabet", you can't expect .NET to supply that for you
very easily, because it has to take every world culture into account.
So, back to your problem, this is where I usually just throw up my
hands and make a string:
const string alphabet="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
public char NextLetter(char letter)
{
return alphabet[alphabet.IndexOf(letter) % alphabet.Length];
}
Not very elegant... but as I pointed out, if you want elegant then you
have a long road ahead of you.
