目前,我编写客户端-服务器垃圾代码,并大量处理通过网络传递的 C++ 结构。我知道这里提供的方法Read a C/C++ data structure in C# from a byte array,但它们都是关于制作副本的。
我想要这样的东西:
struct/*or class*/ SomeStruct
{
public uint F1;
public uint F2;
public uint F3;
}
稍后在我的代码中,我想要这样的东西:
byte[] Data; //16 bytes that I got from network
SomeStruct PartOfDataAsSomeStruct { get { return /*make SomeStruct instance based on this.Data starting from index 4, without copying it. So when I do PartOfDataAsSomeStruct.F1 = 132465; it also changes bytes 4, 5, 6 and 7 in this.Data.*/; } }
如果这是可能的,请告诉如何?