C
C#2y ago
Victor H

❔ Switch-case on byte as characters like in C

Hi can I switch case on bytes using character syntax without having to cast to byte? Just wondering if I can make it look nicer without having to write 32 for space for example and not having to cast.
byte c;
switch (c) {

// I preferably don't want to have to do either of these
case (byte) ' ':
case (byte) 32:

// Preferably:
case ' ':
}
byte c;
switch (c) {

// I preferably don't want to have to do either of these
case (byte) ' ':
case (byte) 32:

// Preferably:
case ' ':
}
3 Replies
Thinker
Thinker2y ago
You can just do switch ((char)c)
Victor H
Victor HOP2y ago
Thanks 🙂
Accord
Accord2y ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server