Discussion Board
Go to the previous messageGo to the following message
Current Forum: Homework 3 Forum
Date: Thu Sep 27 2001 10:49 pm
Author: Liu, Limin Angela <laliu@andrew.cmu.edu>
Subject: Re: ASCII to (1-256)

I tested two ways of doing it, 'A' as example:

- From char to int:
char ch = 'A';
int in = ch; // i = 65, no casting necessary

- From int to char:
int in = 65;
char ch = (char)in; // ch = 'A'

-- Also, Aditya showed a casting to byte in recitation:
char ch = 'A';
byte bt = (byte)ch; //bt = 65

byte bt = 65;
char ch = (char)bt; // ch='A'

You don't have to worry about not casting when needed, because the compiler should catch that. Good luck!
Post response

Go to the previous messageGo to the following message
Current Thread Detail:
ASCII to (1-256)      Shi, Ying      Thu Sep 27 2001 9:34 pm       
Re: ASCII to (1-256)      Dozzi, Giancarlo      Thu Sep 27 2001 10:08 pm       
Re: ASCII to (1-256)      Ghosh, Debmallo S.      Mon Oct 1 2001 11:03 am       
Re: ASCII to (1-256)      Liu, Limin Angela      Thu Sep 27 2001 10:49 pm       
Re: ASCII to (1-256)      Lee, Peter      Fri Sep 28 2001 9:46 am       
Re: ASCII to (1-256)      White, David      Mon Oct 1 2001 9:07 am       

Back to previous screen