using System; using System.Runtime.InteropServices; [StructLayout(LayoutKind.Explicit)] struct ByteToUlongConverter { [FieldOffset(0)] public byte[] bytes; [FieldOffset(0)] public ulong[] ulongs; public ByteToUlongConverter(byte[] bytes) { this.ulongs = null; this.bytes = bytes; } } public class Test { public static void Main() { byte[] bytes = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 }; ByteToUlongConverter conv = new ByteToUlongConverter(bytes); foreach (ulong ul in conv.ulongs) Console.WriteLine($"{ul:X16}"); } }