【发布时间】:2009-06-17 13:30:06
【问题描述】:
我正在使用此代码从 tcpclient 返回一些字符串,但是当字符串返回时,它有一个前导 " 字符。我正在尝试删除它,但 Len() 函数正在读取字节数而不是字符串本身。我怎样才能改变它来给我通常使用它的字符串的长度,而不是字符串本身的数组的长度?
Dim bytes(tcpClient.ReceiveBufferSize) As Byte
networkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize))
' Output the data received from the host to the console.'
Dim returndata As String = Encoding.ASCII.GetString(bytes)
Dim LL As Int32 = Len(returndata)
Len() 报告的是字节数而不是字符串中的字符数。
【问题讨论】:
-
LEN 应该可以工作。您可能想查看各个字符/字节以了解其中的实际内容。
标签: vb.net string ascii tcpclient