Created
March 9, 2017 05:03
-
-
Save runewake2/6489f4b3b021dbcb90c6d86953b6e8ab to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace CSharp7PatternMatching | |
{ | |
// Built for World of Zero: https://youtu.be/PQucU3VFiBA | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
for (int i = 1; i < 100; ++i) | |
{ | |
switch ((x: i % 3 == 0, y: i % 5 == 0)) | |
{ | |
case var fizzBuzz when fizzBuzz.x == true && fizzBuzz.y == true: | |
Console.WriteLine("Fizz Buzz"); | |
break; | |
case var fizz when fizz.x == true && fizz.y == false: | |
Console.WriteLine("Fizz"); | |
break; | |
case var buzz when buzz.x == false && buzz.y == true: | |
Console.WriteLine("Buzz"); | |
break; | |
case var result when result.x == false && result.y == false: | |
Console.WriteLine($"{i}"); | |
break; | |
} | |
} | |
Console.ReadLine(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment