fork download
  1. using System;
  2.  
  3. public class Test
  4. {
  5. public static void Main()
  6. {
  7. byte p = 0xAA;
  8. ushort n = 0x55;
  9.  
  10. Console.WriteLine("0x{0:X2}", p);
  11. Console.WriteLine("0x{0:X2}", n);
  12.  
  13. // первые два бита
  14. p&=0x03;
  15. // Эти два бита приделываешь 8 и 9 битом в n
  16. n |= (ushort)(p<<8);
  17.  
  18. Console.WriteLine("0x{0:X4}", n);
  19. }
  20. }
Success #stdin #stdout 0.04s 24112KB
stdin
Standard input is empty
stdout
0xAA
0x55
0x0255