C# Language: Changing the First Four Bits in a Byte

后端 未结 9 1296
名媛妹妹
名媛妹妹 2021-02-14 07:01

In order to utilize a byte to its fullest potential, I\'m attempting to store two unique values into a byte: one in the first four bits and another in the second four bits. How

9条回答
  •  隐瞒了意图╮
    2021-02-14 07:41

    A quick look would indicate that a bitwise and can be achieved using the & operator. So to remove the first four bytes you should be able to do:

    byte value1=255; //11111111
    byte value2=15; //00001111
    
    return value1&value2;
    

提交回复
热议问题