Copying byte array to various fields in class/struct in C#
问题 In the example C# code below, I have a byte array which has been read from a socket. I want to parse the data into the various fields of 'exampleClass' (first 8 bytes into the 64-bit variable 'field1', next 4 bytes into 32-bit variable 'field2', etc.) using System; namespace CsByteCopy { class Program { class ExampleClass { public UInt64 field1; public UInt32 field2; public UInt16 field3; public byte[] field4 = new byte[18]; } static void Main(string[] args) { byte[] exampleData = { // These