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

--

--

Blogs about Selenium and Java at https://seleniumjava.com.

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store