I have came across this annoying feature/bug. Assume I have a string with trailing spaces like the following:
string value = "someValue ";
The amount of spaces can vary. So I try to show it in a TextBox
enclosed in begin and end tags to see how it varies, and it works perfectly.
textBox1.Text = $"BEGIN#{value}#END";
But the device that send me this value likes to add a \0
null character at the end like this:
string value = "someValue " + Convert.ToChar(0x00);
and when I try to display it with the same method:
textBox1.Text = $"BEGIN#{value}#END;
it results in the disappearance of the #END
tag.
The same phenomenon happens in RichTextBox
.
Question: Why does the null character kills/eats the rest of the string? Is it like in C or C++ that it is interpreted as the end of the char array in a string?