© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
3 replies
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
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 ' ':
}
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ C# Arrays/Switch case help
C#CC# / help
3y ago
❔ C# terminal displaying ascii characters like Ð as D
C#CC# / help
3y ago
❔ Switch case on Int type
C#CC# / help
3y ago
❔ Assigning variables in switch case
C#CC# / help
4y ago