I did something similar to your fizzbuzz in C# 8.0:
public static void Main() { for (var i = 1; i < 31; i++) { Console.WriteLine(FizzBuzz(i)); } } public static string FizzBuzz(int number) { return number switch { _ when number % 15 == 0 => "FizzBuzz", _ when number % 3 == 0 => "Fizz", _ when number % 5 == 0 => "Buzz", _ => number.ToString() }; }
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I did something similar to your fizzbuzz in C# 8.0: