On Mon, 17 Mar 2008 21:07:34 -0700, Greg Young <[EMAIL PROTECTED]> wrote:
> chars are numbers underneath ... [...] > if you look at an ASCII table http://www.asciitable.com/ 'a' - 'z' are > conventiently in order numerically ... This only works for the English alphabet. It will not work with the Swedish alphabet, for example. Also, it should be noted that the Encoding used here to convert characters to numbers and subsequently find the "next" character isn't ASCII, strictly speaking. Characters and strings in .NET are mapped directly (and bidirectionally) to Unicode, which is basically a map of all the world's writing. What you are doing when converting the character to an integer is taking several shortcuts which are possible because of, for example, how ASCII is laid out in the various Unicode translation formats for backward compatibility. So while the approach works, it is very old-school. I'd consider the "char++" approach a leaky abstraction, albeit one highly unlikely to cause problems. But do make a note in the code, in case casting a char to an int is deprecated in the next version of .NET. =] Also, read the Community Content comments here: http://msdn2.microsoft.com/en-us/library/system.char.getnumericvalue.aspx =================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com