fork download
  1. using System;
  2. using System.Runtime.InteropServices;
  3.  
  4. [StructLayout(LayoutKind.Explicit)]
  5. struct ByteToUlongConverter
  6. {
  7. [FieldOffset(0)]
  8. public byte[] bytes;
  9.  
  10. [FieldOffset(0)]
  11. public ulong[] ulongs;
  12.  
  13. public ByteToUlongConverter(byte[] bytes)
  14. {
  15. this.ulongs = null;
  16. this.bytes = bytes;
  17. }
  18. }
  19.  
  20. public class Test
  21. {
  22. public static void Main()
  23. {
  24. byte[] bytes = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 };
  25. ByteToUlongConverter conv = new ByteToUlongConverter(bytes);
  26.  
  27. foreach (ulong ul in conv.ulongs)
  28. Console.WriteLine($"{ul:X16}");
  29. }
  30. }
Success #stdin #stdout 0s 29672KB
stdin
Standard input is empty
stdout
0807060504030201
000000000984F300
0000000000000000
0000000009890E50
0807060504030201
000000000984EFE0
0000000100000000
0000000055C007D8