String to Integer Value

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need to check if a character falls within the range of 32 - 127 and 160 -
255. How do I convert a character to the value to make sure it falls within
this acceptable range?
 
Andy said:
I need to check if a character falls within the range of 32 - 127 and 160 -
255. How do I convert a character to the value to make sure it falls within
this acceptable range?

If you have a character you can easily get the Unicode codepoint number:

char c = 'a';
int codePoint = c;
 
I need to check if a character falls within the range of 32 - 127 and 160 -
255. How do I convert a character to the value to make sure it falls
within
this acceptable range?

Sounds like you're looking for the ASCII number of a character, like the old
VB Asc() function...

char strChar = 'A';

int intChar = (int)strChar;
 
Take a look at Int32.Parse
--
Kai Brinkmann [Microsoft]

Please do not send e-mail directly to this alias. This alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Mark Rae said:
Sounds like you're looking for the ASCII number of a character, like the old
VB Asc() function...

char strChar = 'A';

int intChar = (int)strChar;

.... except that values 160-255 aren't within ASCII.

I think he really is after the Unicode value - and the code you gave
does precisely that :)
 
int i = int.Parse(myString);

Nah, that's not what the OP is asking for.

Happy Coding
- Michael S
 
Back
Top