character conversion

  • Thread starter Thread starter DaveP
  • Start date Start date
D

DaveP

hi i want to convert say letter A to its Ascii Value and back to its
Character Value..
im cant Seem To Find how to do this
Tks
DaveP
 
DaveP said:
hi i want to convert say letter A to its Ascii Value and back to its
Character Value..
im cant Seem To Find how to do this

Just convert it to int and back - there's already an implicit
conversion from char to int:

char c = 'A';
int ascii = c;
c = (char) ascii;

Note that this will be the *Unicode* value of any particular char
rather than just the ASCII value. Of course, for all ASCII characters
it's the same thing.
 
Thanks for the Response
DaveP

Jon Skeet said:
Just convert it to int and back - there's already an implicit
conversion from char to int:

char c = 'A';
int ascii = c;
c = (char) ascii;

Note that this will be the *Unicode* value of any particular char
rather than just the ASCII value. Of course, for all ASCII characters
it's the same thing.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top