Switch Expression in C# 8

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...

Switch Expression in C# 8
Introduction C# 8 introduce switch expression, an elegant and compact new way to write switch statements. It's important to note[...]
How Delegates Work in C#
Most developers new to C# don't fully understand how delegates work and it's a frequently asked question in the Productive[...]
Notes from ProgNET London 2019
In the past three days I attended the ProgNET London 2019 conference.Here my key notes from the various sessions and[...]
Getting Started with Server-Side Blazor
Blazor is a feature of ASP.NET Core. It allows developers to build full-stack web applications using C# instead of Javascript. Blazor[...]
Value Types and Reference Types in C#
Extensible fixed statement is a new feature introduced in C# 7.3. Learn how to add support for pinning using the[...]
Free Webinar – Master C# 8 New Features
The next release of the Microsoft flaship programming language is fast approaching.  In this free webinar, I am going deep[...]
Sharing is Caring
>