I can't seem to find any byte array conversion functions to strings.
I'm receiving data via a network packet and want to convert the byte array
contents into there actual character equivilent.
For example
Convert
byte[] byteArray = { 64, 65, some ascii numbers }
To
char[] charArray = { A, B, some characters }
by the way I don't think my ascii numbers are correct
In C++ you would just typecast them but I can't seem to do that.
Francois Beaussier - 11 Jan 2006 04:36 GMT
Hello Daniel,
you can use the following method:
string myStr = System.Text.Encoding.ASCII.GetString(byteArray);
You can use others encoding depending on your needs.

Signature
Francois Beaussier
>I can't seem to find any byte array conversion functions to strings.
> I'm receiving data via a network packet and want to convert the byte array
[quoted text clipped - 8 lines]
>
> In C++ you would just typecast them but I can't seem to do that.
Daniel - 11 Jan 2006 22:23 GMT
This works well
I knew there had to be a solution somewhere!!!
Navigating the docs to find this isn't easy how did you find out about it?
> Hello Daniel,
>
[quoted text clipped - 16 lines]
> >
> > In C++ you would just typecast them but I can't seem to do that.
Francois Beaussier - 11 Jan 2006 22:30 GMT
> Navigating the docs to find this isn't easy how did you find out about it?
hum, I can't remember where I got that one :)

Signature
Francois Beaussier
newbie - 11 Jan 2006 08:41 GMT
you want a conversion from the acii numbers to the characters ?
like chr(32) / returns space
chr(33) /returns !
chr(65) /returns A
asc("A") / returns 65
asc(" ") /returns 32
Make a for next loop and convert your array ?
>I can't seem to find any byte array conversion functions to strings.
> I'm receiving data via a network packet and want to convert the byte array
[quoted text clipped - 8 lines]
>
> In C++ you would just typecast them but I can't seem to do that.
Daniel - 11 Jan 2006 22:21 GMT
This solution works also but I think the other solution is better for my
purposes just because it converts the whole array at once.
Thanks for your input though I can see where I would use this tecnique over
the other one.
> you want a conversion from the acii numbers to the characters ?
> like chr(32) / returns space
[quoted text clipped - 18 lines]
> >
> > In C++ you would just typecast them but I can't seem to do that.