C# tip— change switch statements to switch expressions

Photo by Karim MANJRA on Unsplash

I am not a big fan of the switch statement.

For all the classic reasons:

  • it is difficult to maintain
  • it provides an opportunity for redundant code
  • switching on type is usually a code smell
  • it is so long