Advertisement
uniblab

Untitled

Jul 7th, 2017
362
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.60 KB | None | 0 0
  1. public static class Program {
  2.  
  3.     [System.Runtime.InteropServices.StructLayout( System.Runtime.InteropServices.LayoutKind.Explicit )]
  4.     private struct Union {
  5.         [System.Runtime.InteropServices.FieldOffset( 0 )]
  6.         public System.Byte ByteField;
  7.         [System.Runtime.InteropServices.FieldOffset( 0 )]
  8.         public System.Boolean BooleanField;
  9.     }
  10.  
  11.     [System.STAThread]
  12.     public static System.Int32 Main( System.String[] args ) {
  13.  
  14.         var u1 = new Union {
  15.             ByteField = 1
  16.         };
  17.         var u2 = new Union {
  18.             ByteField = 2
  19.         };
  20.         System.Console.Out.WriteLine( u1.BooleanField == u2.BooleanField );
  21.  
  22.         return 0;
  23.     }
  24.  
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement