bug3.cs 555 B

123456789101112131415161718192021222324252627282930313233343536
  1. //
  2. // Fixed, incorporated into test
  3. //
  4. using System;
  5. using System.Runtime.InteropServices;
  6. [StructLayout (LayoutKind.Explicit)]
  7. struct A {
  8. [FieldOffset (0)]
  9. public int a;
  10. [FieldOffset (0)]
  11. public byte b1;
  12. [FieldOffset (1)]
  13. public byte b2;
  14. [FieldOffset (2)]
  15. public byte b3;
  16. [FieldOffset (3)]
  17. public byte b4;
  18. }
  19. class X {
  20. static void Main ()
  21. {
  22. A a = new A ();
  23. a.a = 0x12345678;
  24. Console.WriteLine ("b1: " + a.b1);
  25. Console.WriteLine ("b2: " + a.b2);
  26. Console.WriteLine ("b3: " + a.b3);
  27. Console.WriteLine ("b4: " + a.b4);
  28. }
  29. }