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!
|
|