-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
45 lines (41 loc) · 1.22 KB
/
Program.cs
File metadata and controls
45 lines (41 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using System;
namespace PatternMatching
{
class Program
{
static void Main(string[] args)
{
SimpleUsage();
// PerformOperation("SystemTest");
}
// simple usage
static void SimpleUsage()
{
int input = 8;
int sum = 0;
if (input is int count)
sum += count;
Console.WriteLine(sum);
}
// Compare discrete values, see Version 8.0
//static int PerformOperation(string command) =>
// command switch
// {
// "SystemTest" => 0,
// "Start" => 1,
// "Stop" => 2,
// "Reset" => 3,
// _ => throw new ArgumentException("Invalid string value for command", nameof(command)),
// };
// Relational patterns, see Version 9.0
//string WaterState(int tempInFahrenheit) =>
// tempInFahrenheit switch
// {
// (> 32) and (< 212) => "liquid",
// < 32 => "solid",
// > 212 => "gas",
// 32 => "solid/liquid transition",
// 212 => "liquid / gas transition",
// };
}
}