嗨,我有一個結構如下結構字節字段整理爲byte []
private struct MessageFormat
{
public byte[] Header; //start of message
public byte Fragmentation; //single packet or not
public byte Encryption; //encrypted message
public byte[] Authentication; //password
public byte[] Flag; //to locate end of auth
public byte[] Data; //info
public byte[] Trailer; //end of message
}
是有整個的MessageFormat轉換成一個字節數組[後,我填寫的所有字段]一種方便的方法?
嘗試查找BitArray類。 –
有一個方便的方法,但你可能不會喜歡它。 .NET框架方式煩惱了很多,確保byte []可以安全地轉換回原始對象。不太方便的方法是BinaryWriter。 –