I have a byte array that may or may not have null bytes at the end of it. After converting it to a string I have a bunch of blank space at the end. I tried using Trim() to get rid of it, but it doesn’t work. How can I remove all the blank space at the end of the string after converting the byte array?
I am writing this is C#.
In the interest of full disclosure, I’d like to be very clear that this will only work reliably for ASCII. For any multi-byte encoding this will crap the bed.