0

how to use byte to show msg in c# (CS)

input string 1. 11111111 2. 11010111 3. 00000000 (vice versa) output 1. issue 1, issue 2, issue 3, issue 4, issue5, issue6, issue7, issue8 2. issue 1, issue 2, issue 4, issue 6, issue 7, issue 8 3. I thought I should do it as below, but I don't know what is the next. Please help. public bool IsBitSetTo1( int value, int position) { return (value & (1 << position)) != 0; }

4th Jun 2022, 2:55 PM
Pong Prince
Pong Prince - avatar
2 Antworten
+ 3
// this can be do in this way: int value = 0x10110100; int checkBit = 0x00010000; bool hasBit = (value & checkBit) == checkBit;
4th Jun 2022, 3:08 PM
JaScript
JaScript - avatar
+ 3
It says in the Description: "Input string: ..." If as it says, input were string, then there should be no need for bit operation here, except it was a typo of course ...
4th Jun 2022, 3:14 PM
Ipang