Further to solution 1 it also depends on what you mean by "the last character of ASCII" - this may depend on the Code Page in use. A discussion
here[
^] explains it better than me.
This little function will valiantly try to find the next printable character
private char NextLetter(char letterIn)
{
int a = (int)letterIn + 1;
char ret;
if (char.IsLetterOrDigit((char)a) || char.IsSymbol((char)a) || char.IsPunctuation((char)a))
ret = ((char)a);
else
{
ret = NextLetter((char)a);
}
return ret;
}
Calling it from a too-large loop skips the non-printable stuff ... i.e. output starts at "!"
E.g.
for (int i = 0; i < 300; i++)
Debug.Print(NextLetter((char)i).ToString());