How do I get rid of null chars in a Char() or a String? I have the following Structure and code and the result of it is a String tailling by space (or null?). For example, if the output is supposed to be "ABC", "ABC " (13 space/nulls) is outputed instead. And Trim() is not working. Please help. Thanks.
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi, Pack:=1)> Public Structure DATA
<VBFixedString(16), MarshalAs(UnmanagedType.ByValArray, SizeConst:=16)> Public ABBR As Char()
Dim d As DATA
Dim mystring As String
d = CType(Marshal.PtrToStructure(New IntPtr(tBankScan), GetType(DATA)), DATA)
mystring = d.ABBR
Console.WriteLine("""" & mystring.TrimEnd & """")