A Collection of Code Snippets in as Many Programming Languages as Possible
This project is maintained by TheRenegadeCoder
Welcome to the Fizz Buzz in C# page! Here, you’ll find the source code for this program as well as a description of how the program works.
namespace FizzBuzz
{
public class Program
{
public static string FizzBuzz(int number)
{
string temp = "";
if (number % 3 == 0)
{
temp += "Fizz";
}
if (number % 5 == 0)
{
temp += "Buzz";
}
if (string.IsNullOrEmpty(temp))
{
temp += number;
}
return temp;
}
private static void Main(string[] args)
{
for (int i = 1; i <= 100; i++)
{
string line = FizzBuzz(i);
System.Console.WriteLine(line);
}
}
}
}
Fizz Buzz in C# was written by:
If you see anything you’d like to change or update, please consider contributing.
Note: The solution shown above is the current solution in the Sample Programs repository as of Mar 26 2019 00:00:41. The solution was first committed on Aug 14 2018 11:18:18. As a result, documentation below may be outdated.
No ‘How to Implement the Solution’ section available. Please consider contributing.
No ‘How to Run the Solution’ section available. Please consider contributing.