switch with Constant Patterns
Constant patterns match the expression against a constant value.
char grade = 'B';switch (grade){ case 'A': Console.WriteLine("Excellent"); break; case 'B': Console.WriteLine("Good"); break; case 'C': Console.WriteLine("Fair"); break; default: Console.WriteLine("Needs improvement"); break;}Run the Application
Section titled “Run the Application”dotnet runResult
Section titled “Result”Good