By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,127 Members | 1,343 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,127 IT Pros & Developers. It's quick & easy.

Converting byte[] to string - removing NULLs??

P: n/a
Hello,
I've eliminated the bulk of code, this should be sufficient:

byte[] fromEncrypt;
string sDecryptedString;

//Read the data out of the crypto stream.
csDecrypt.Read(fromEncrypt, 0, fromEncrypt.Length);

//At this point in the debugger, I can see there are "trailing" NULLs '\0'
in several of the last fromEncrypt array elements

//Convert the byte array back into a string.
sDecryptedString = textConverter.GetString(fromEncrypt);

I can see β€˜\0’ in a number of the array elements of fromEncrypt (at the end
of the array). When I put that into the sDecryptedString, the nulls are
still there.

Other than using a β€œfor” loop and parsing each element, is there a single
command that can remove the trailing nulls from either the fromEncrypt or the
sDecryptedString?

..Trim() or .Trim('\0') didn't work.

Thanks!! Jeff
Jan 26 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Disregard this!

Sorry, kids. I meant to put this under C#.
Thanks.
Jan 26 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.