Strings in .NET are not null terminated, allowing the null character to be a
valid character in a string.
To put a null character in a string, you can simply append/concatenate it to
the string.
Const StringWithEmbeddedNull As String _
= "A string with an embedded " _
& ControlChars.NullChar _
& " null char"
If you need to pass a string to a Win32 or COM API a null character is
normally appended for you by the marshaller, so you do not need to worry
about it. In fact having a string with a null character in it can confuse
the marshaller, as it stops copying strings at the null character...
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.