1
Answer

Malfunction: byte 256 to string

Jacob R

Jacob R

14y
2.9k
1

I'm getting a byte array from a server on the return it is set up like..
byte
[] myBytes = new byte[256];
Now when I try to convert it to a string with ASCIIEncoding it get the string and then I get the rest of the 256 characters as /0/0/0/0/0 ect...  I've tried
string.Replace("\\0", ""); and it didn't take them away.  I've also tried .Remove() but once It hits the .Indexof("\\0") I get an error like they aren't even there. 
To encode I tried:
s =
new string(Encoding.ASCII.GetChars(myBytes));
s =
ASCIIEncoding.ASCII.GetString(myBytes);
s =
Encoding.ASCII.GetString(myBytes, 0, myBytes.Length);
and nothing seems to work to get rid of all of the /0/0/0's
help me plz

Answers (1)