Last active
October 17, 2017 14:07
-
-
Save melanore/c63b0f9ea167d1a3760ba483e5656edd to your computer and use it in GitHub Desktop.
This file contains 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
var result = Enumerable.Range(1, 100) | |
.Select(i => | |
{ | |
switch ((Fizz: i % 3, Buzz: i % 5)) | |
{ | |
case var t when t.Fizz == 0 && t.Buzz == 0: return $"{nameof(t.Fizz)}{nameof(t.Buzz)}"; | |
case var t when t.Fizz == 0: return $"{nameof(t.Fizz)}"; | |
case var t when t.Buzz == 0: return $"{nameof(t.Buzz)}"; | |
default: return i.ToString(CultureInfo.InvariantCulture); | |
} | |
}) | |
.Aggregate(new StringBuilder(), (builder, s) => builder.AppendLine(s)); | |
Console.WriteLine(result); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment