Tech
Forums
Jobs
Books
Events
Videos
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
1
Answer
Malfunction: byte 256 to string
Jacob R
14y
2.9k
1
Reply
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
Post
Reset
Cancel
Answers (
1
)
Next Recommended Forum
Export to Excel
Leaving a textbox after deletng content with backspace