Write a program that prints the numbers from 1 to 100. But for multiples of three
print "Fizz" instead of the number and for the multiples of five print "Buzz". For
numbers which are multiples of both three and five print "FizzBuzz".
FizzBuzz is a great way to practice concepts like ternary statements and extension methods.
It's a fun problem because there are a
million ways to solve it.
This is not something I would use in an interview. I just wanted to see if I could get this down to one line.
I am a big fan of guard clauses because they show you what conditions cause the program to exit the method.
Not everyone agrees with guard clauses. Here is an example of single entry and single exit code.
Extension methods allow you to extend C# data types with new methods.