Syntax of Switch Expressions
A switch expression uses => to map patterns to results.
int number = 5;string parity = number % 2 == 0 ? "Even" : "Odd";string description = numberswitch{ < 0 => "Negative", 0 => "Zero", > 0 => "Positive"};Console.WriteLine($"{parity}, {description}");Run the Application
Section titled “Run the Application”dotnet runResult
Section titled “Result”Odd, Positive