Skip to content

Elementary C# Question

Joe

Asked Aug 21, 2006, 5:57 AM EDT2 answers
Share
LinkedInX
I have a string value with garbage and can not strip out the bad (or I believe null) characters.

The string looks like this:

"XYZ Corporation\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"

I believe these are escape sequences showing null values.  I tried TrimEnd, Replace, Trim, etc. and can not find a way to strip out all of the "\0" occurrences. 

Any idea what I can do?  It's driving me nuts.

2 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    Hi! You can compare the ascii value of each character and then reassign the string value. milind
    0
  • 0
    Try using str.Replace(chr(0),"").
    0