Constant pattern
Context: The constant pattern tests whether an expression equals a constant value (literal, null, or const).
int value = 5;if (value is 5){ Console.WriteLine("It's five");}
// In switch expressionstring result = value switch{ 1 => "One", 2 => "Two", _ => "Other"};Real-world usage example
Section titled “Real-world usage example”Command handling: Use constant pattern to match specific command types in a switch expression (e.g., case "CREATE": ...).
Example: In a TCP server, you might parse string commands and use constant pattern.