C
C#10mo ago
bl4ck

Can't use | operator in case?

This does nothing for some reason, and yes the id is 1
No description
6 Replies
ThatDaniel
ThatDaniel10mo ago
I think it's doing a bitwise operation
ThatDaniel
ThatDaniel10mo ago
Bitwise and shift operators - perform boolean (AND, NOT, OR, XOR) a...
Learn about C# operators that perform bitwise logical (AND - &, NOT - ~, OR - |, XOR - ^) or shift operations( <<, and >>) with operands of integral types.
ThatDaniel
ThatDaniel10mo ago
You can change it to
case 1 or 7:
int offset = 0;
//rest of code...
case 1 or 7:
int offset = 0;
//rest of code...
or
case 1:
case 7:
int offset = 0;
//rest of code...
case 1:
case 7:
int offset = 0;
//rest of code...
bl4ck
bl4ckOP10mo ago
ah thanks!
oke
oke10mo ago
(Not C# Relevant) using '|' instead of "||" is valid syntax for bash script, so you weren't far off from something real
val="value"

case val in
"val1" | "val2") do_something ;;
esac
val="value"

case val in
"val1" | "val2") do_something ;;
esac
bl4ck
bl4ckOP10mo ago
interesting
Want results from more Discord servers?
Add your server