Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save JustinJohnWilliams/d93f45f70d0f2cbfb5acc82dbca0ef9f to your computer and use it in GitHub Desktop.
Save JustinJohnWilliams/d93f45f70d0f2cbfb5acc82dbca0ef9f to your computer and use it in GitHub Desktop.
{
{ new Func<int, bool>(x => x % 3 == 0), new Func<int, string>(x => "Fizz") },
{ new Func<int, bool>(x => x % 5 == 0), new Func<int, string>(x => "Buzz") },
{ new Func<int, bool>(x => x % 3 != 0 && x % 5 != 0), new Func<int, string>(x => x.ToString()) },
{ new Func<int, bool>( x => true), new Func<int, string>(x => "\n" ) }
};
var output = from n in Enumerable.Range(1, 100)
from f in rules
where f.Key(n)
select f.Value(n);
output.ToList().ForEach(Console.WriteLine);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment