99 Bottles

The Approach

It would be simple, although very dull, to just make a quick loop to go from 99 to 0:

// A very dull, lifeless way to sing the 99 Bottles song.

using System;

public class SingTheSong
{
   public static void Main()
   {
       int count = 99;

       while (count < 99)
       {
           System.Console.WriteLine("{0} bottles of beer on the wall,", count);
           System.Console.WriteLine("{0} bottles of beer.", count);
           System.Console.WriteLine("Take one down, pass it around,");
           --count;
           System.Console.WriteLine("{0} bottles of beer on the wall,", count);
           System.Console.WriteLine();
       }
   }
}

There's no cachet in that, if you ask me. What if I want to drink something else? What if I want more (or less) than 99? What do I do when I run out? Do I really want to sing "1 bottles of beer"? How do I send the output to, say, a browser instead of the console?

No, that just wouldn't do.

You might also like...

Comments

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.”