我不是套接字编程的老手,所以在分析我在数据库 API 中找到的代码时,我遇到了这段代码
public static void WriteInt(int i, NetworkStream bufOutputStream)
{
byte[] buffer = new byte[IntSize];
WriteInt(i, buffer, 0);
bufOutputStream.Write(buffer, 0, buffer.Length);
}
public static void WriteInt(int i, byte[] byte_array, int pos)
{
byte_array[pos] =(byte)( 0xff & (i >> 24)); byte_array[pos+1] = (byte)(0xff & (i >> 16)); byte_array[pos+2] = (byte)(0xff & (i >> 8)); byte_array[pos+3] = (byte)(0xff & i);
}
我理解位移我不理解的是,当 args 中没有ref或没有返回时,'buffer' var 如何不断获取值。位移以某种方式编辑缓冲区的实际值?