C# 8.0 Switch Expression vs Classic Switch Case

0
24



C# 8.0 Switch expressions enable you to use more concise expression syntax. There are fewer repetitive case and break keywords, and fewer curly braces.

There are several syntax improvements here:
– The variable comes before the switch keyword.
– The case and : elements are replaced with lambda expression (arrow key).
– The default case is replaced with a _ discard.
– The bodies are expressions, not statements.

Nguồn:https://wijstaanvooronzegrondrechten.org/

LEAVE A REPLY

Please enter your comment!
Please enter your name here