Home All Groups Group Topic Archive Search About

Convert ascii code to string

Author
27 Nov 2004 6:44 PM
Daniel Passwater via DotNetMonster.com
I am working on an app that is receiving hex numerical values via serial connection. I am now to the point that I have converted each byte into its ascii code value. Could comeone please tell me how to convert 48 to 0, 49 to 1, etc? I need to display this in a textbox.
Thanks in advance for any and all help.

--
Message posted via http://www.dotnetmonster.com

Author
27 Nov 2004 7:20 PM
Jon Skeet [C# MVP]
Daniel Passwater via DotNetMonster.com <fo***@DotNetMonster.com> wrote:
> I am working on an app that is receiving hex numerical values via
> serial connection. I am now to the point that I have converted each
> byte into its ascii code value. Could comeone please tell me how to
> convert 48 to 0, 49 to 1, etc? I need to display this in a textbox.

If you've got an array of such bytes, the easiest way is to use
Encoding.ASCII.GetString (theByteArray);

To convert a single byte into a string, use ((char)theByte).ToString();

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Author
28 Nov 2004 2:37 AM
Daniel Passwater via DotNetMonster.com
That worked like a charm. Thanks.

--
Message posted via http://www.dotnetmonster.com

AddThis Social Bookmark Button