dim bytes(tcpC.ReceiveBufferSize) As Byte
dim ret as integer = netStream.Read(bytes, 0, bytes.length)
dim returndata As String = Encoding.ASCII.GetString(bytes)byte[] bytes= new byte[tcpC.ReceiveBufferSize] ;
int ret = netStream.Read(bytes, 0, bytes.length)
string returndata = Encoding.ASCII.GetString(bytes)
dim ret as integer = netStream.Read(bytes, 0, bytes.length)
dim returndata As String = Encoding.ASCII.GetString(bytes)byte[] bytes= new byte[tcpC.ReceiveBufferSize] ;
int ret = netStream.Read(bytes, 0, bytes.length)
string returndata = Encoding.ASCII.GetString(bytes)
int ret = netStream.Read(byte, 0, bytes.Length);
string returndata = Encoding.ASCII.GetString(bytes);VB里面Dim a(1) As Byte 实际上是有两个元素的。(0到1)
C#里面byte[] a = new byte[1] 好像只有一个元素。(只有0)
不知道我说的正不正确?
正确的程序如下:
byte[] bytes = new byte[tcpC.ReceivedBufferSize + 1];
int ret = netStream.Read(byte, 0, bytes.Length);
string returndata = Encoding.ASCII.GetString(bytes,0,ret);