I'm pretty new to C# and I have to handle a byte stream that I receive. In C++ I usually used something like that:
#pragma pack(push, DTA_VLS, 1)
typedef struct tsHEADER
{
WORD wLength;
WORD wIdCounter;
WORD wxxxx;
WORD wxxxx2;
} tHEADER;
#pragma pack(pop, DTA_VLS)
and then when I received a byte array I could do something like that:
tHEADER header*;
header = receivedByteArray;
if(header->wLength >0)
{
do something
}
Is there something similar I could do in C# when I want to read a received telegram or create a new one? Or can I do only something like that:
byte[] Tel= new byte(5);
byte[0]= Length;
byte[1]=ID;
// and so on