So I have a gigantic byte-array that represents a data packet. There’s various parts of the packet such as a header, message body, stop bits, etc. How can I create variables of the various parts of the array such that when I reference the variable I’m editing the sub-array? I’d like to use the dot notation so that referencing ByteArrayRepresentingPacket.Header would actually reference ByteArrayRepresentingPacket[0], ByteArrayRepresentingPacket.MessageBody would actually reference ByteArrayRepresentingPacket[1] through ByteArrayRepresentingPacket[8], etc. A structure seems suited for this, but how would I translate the structure into a byte-array when I need to pass it?
So I have a gigantic byte-array that represents a data packet. There’s various parts
Share
So I ended up going with a structure (like I had hoped I could). Here’s the implementation:
I kept everything as
IEnumerableso that I could just use LINQ’s.Concatoperator (to make everything clean & concise). What I’m unsure of is if the performance savings I gain from using a struct (no boxing/unboxing) will be undone by usingIEnumerableProperties and LINQ