我有以下代码:
while (!isCancellationRequested)
{
byte[] frameBytes = socket.ReceiveFrameBytes();
MyData data = new MyData();
data.Deserialize(frameBytes);
// send the data somewhere somehow...
}
我想做的,但我在文档中找不到可以避免在每个上创建新字节数组的东西socket.Receive
:
byte[] frameBytes = new byte[123];
while (!isCancellationRequested)
{
socket.ReceiveFrameBytes(frameBytes);
MyData data = new MyData();
data.Deserialize(frameBytes);
// send the data somewhere somehow...
}
我怎样才能做到这一点?