Skip to content

Instantly share code, notes, and snippets.

@runewake2
Created March 9, 2017 05:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save runewake2/6489f4b3b021dbcb90c6d86953b6e8ab to your computer and use it in GitHub Desktop.
Save runewake2/6489f4b3b021dbcb90c6d86953b6e8ab to your computer and use it in GitHub Desktop.
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