January 8

Switch Expression in C# 8

2  comments

Introduction

C# 8 introduce switch expression, an elegant and compact new way to write switch statements.

It's important to note that the switch expression is not a replacement to the classic switch statement but it can be used in the majority of the situations. What you can do with the switch expression can always be done with a switch statement but not the opposite. 

In this video, you will learn how you can convert a classic switch statement to the new syntax and the limitations of this new feature.

Practical Video

Conclusion

Honestly I think the switch expression is the best feature added to the C# 8 language. It's a feature that can greatly impact you code bases by making them easier to read. My recommendation is to always use switch expressions unless you hit a limitation and you are forced to rely on the old classic switch statement.

Keep Learning...

Top 10 C# Developers Videos from .NET Conf 2021
Last week, Microsoft announced .NET 6 and C# 10 at the .NET Conf 2021. It's the most important release in[...]
The best way to stay up to date with C# 10 features
C# is a language that is constantly evolving and it can be hard to stay up to date with all[...]
My Technical Journey from my first program to Lead Software Engineer
I was recently interviewed by Sean Rajnis and I shared with him my programming journey. This is a quick summary:[...]
Top 10 C# Developer News from Microsoft Build 2020
The Microsoft Build 2020 conference this year is completely free. Watch the live event on the official Build 2020 website.[...]
Agile Estimation
Designed by ijeab / Freepik I'd like to share with you some of my notes after taking the course on Agile[...]
Nullable Reference Types in C# 8
Introduction C# 8 introduce switch expression, an elegant and compact new way to write switch statements. It's important to note[...]

Tags


You may also like

  • {"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

    Subscribe to our newsletter now!

    Get instant access to the Master C# 9 webinar to learn all the new exciting C# 9 features quickly.
    Get regular videos and news on C# and .NET and offers on products and services to master C#.

    We will collect, use and protect your data in accordance with our Privacy Policy.

    >