Skip to content

Instantly share code, notes, and snippets.

Created October 17, 2017 08:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/84acb6e4be006ce8e22968c639a668c7 to your computer and use it in GitHub Desktop.
Save anonymous/84acb6e4be006ce8e22968c639a668c7 to your computer and use it in GitHub Desktop.
using System;
namespace FizzBuzz
{
class Program
{
static void Main(string[] args)
{
for(int i=1;i<=100;i++) {
switch ((i % 3, i % 5)) {
case System.ValueTuple<int, int> t when t.Item1 == 0 && t.Item2 == 0:
Console.WriteLine("FizzBuzz");
break;
case System.ValueTuple<int, int> t when t.Item1 == 0:
Console.WriteLine("Fizz");
break;
case System.ValueTuple<int, int> t when t.Item2 == 0:
Console.WriteLine("Buzz");
break;
default:
Console.WriteLine(i);
break;
}
}
}
}
}
@DavidArno
Copy link

DavidArno commented Oct 17, 2017

You can change your case System.ValueTuple<int, int> t expressions to case var t

@melanore
Copy link

I'd prefer a to stick with LINQ and named tuples.
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment