Concept Flow - Constant patterns
Start
Match value with constant pattern
End
The program checks if a value matches a constant pattern. If yes, it runs matched code; if no, it runs other code or skips.
int number = 5; if (number is 5) { Console.WriteLine("Number is five"); } else { Console.WriteLine("Number is not five"); }
| Step | Variable 'number' | Condition 'number is 5' | Branch Taken | Output |
|---|---|---|---|---|
| 1 | 5 | True | If branch | Number is five |
| 2 | 5 | N/A | End | Program ends |
| Variable | Start | After Step 1 | Final |
|---|---|---|---|
| number | 5 | 5 | 5 |
Constant patterns check if a value equals a fixed constant. Syntax: 'variable is constantValue'. If true, matched code runs. If false, else or other code runs. Useful for clear, readable condition checks.