1
Supposons que nous avons deux C# structures:Comment transformer une structure C# en une autre comme en C++?
[Serializable, StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct ByteStructure
{
public byte byte0;
public byte byte1;
public byte byte2;
public byte byte3;
public byte byte4;
public byte byte5;
public byte byte6;
public byte byte7;
public byte byte8;
public byte byte9;
public byte byteA;
public byte byteB;
public byte byteC;
public byte byteD;
public byte byteE;
public byte byteF;
}
[Serializable, StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct IntStructure
{
public int i0;
public int i1;
public int i2;
public int i3;
}
ByteStructure bs;
IntStructure is;
...
Comment transformer une structure à l'autre comme en C++:
is = (IntStructure)bs;
ou
bs = (ByteStructure)is;