Skip to content

Instantly share code, notes, and snippets.

@ssta604
Created October 18, 2022 02:53
Show Gist options
  • Save ssta604/a36c006df02e6f94fa2508a846d2cd8d to your computer and use it in GitHub Desktop.
Save ssta604/a36c006df02e6f94fa2508a846d2cd8d to your computer and use it in GitHub Desktop.
using System;
using System.Linq;
var output =
Enumerable.Range(1, 50)
.Select<int, string>((num) => num + ": " + (num % 3 == 0, num % 5 == 0)
switch
{
(true, true) => "FizzBuzz",
(true, false) => "Fizz",
(false, true) => "Buzz",
_ => num.ToString(),
});
output.ToList().ForEach(x=> Console.WriteLine(x));
1: 1
2: 2
3: Fizz
4: 4
5: Buzz
6: Fizz
7: 7
8: 8
9: Fizz
10: Buzz
11: 11
12: Fizz
13: 13
14: 14
15: FizzBuzz
16: 16
17: 17
18: Fizz
19: 19
20: Buzz
21: Fizz
22: 22
23: 23
24: Fizz
25: Buzz
26: 26
27: Fizz
28: 28
29: 29
30: FizzBuzz
31: 31
32: 32
33: Fizz
34: 34
35: Buzz
36: Fizz
37: 37
38: 38
39: Fizz
40: Buzz
41: 41
42: Fizz
43: 43
44: 44
45: FizzBuzz
46: 46
47: 47
48: Fizz
49: 49
50: Buzz
{
"version": 1,
"target": "Run",
"mode": "Debug"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment