// good bye and thank you for all the fish
/* 
Der Algorithmus:
In einer aeusseren Schleife die Tiere nach der Liste vorwaerts zaehlen,
in einer inneren Schleife deren Geraeusche RUECKWAERTS, beginnend beim
aktuellen Tier, bis zum ersten zurueck zaehlen. Die Strophen werden 
dabei immer laenger.
*/
using System;

class MainClass
{
    // weil in C# "const" nicht auf initialisierte arrays angewendet werden kann, muss "readonly" herhalten 
    static readonly string[] aszAnimals = {"chicks","cows","pigs","dogs","cats", "sheep", "horses", "fish"};
    static readonly string[] aszAnimalSounds = {"cluck" ,"moo", "oink","woof","meow", "baah",  "neigh", "blub"};

    const int MAX_ANIMALS = 8;

    public static void Main(string[] args)
      {
      Console.Write("How many Animals: ");
      // Exception ignoriert.
      int nNumAnimals = Int32.Parse(Console.ReadLine());

/***************************************************************************
******************** Variante mit switch() *********************************
****************************************************************************/

      for (int nAnimal = 0; nAnimal < nNumAnimals; nAnimal++)
         {
         string strAnimals;
         
         switch (nAnimal)
            {
            case 0:
                strAnimals = "chicks";
                break;
            case 1:
                strAnimals = "cows";
                break;
            case 2:
                strAnimals = "pigs";
                break;
            case 3:
                strAnimals = "dogs";
                break;
            case 4:
                strAnimals = "cats";
                break;
            case 5:
                strAnimals = "sheep";
                break;
            case 6:
                strAnimals = "horses";
                break;
            case 7:
                strAnimals = "fish";
                break;
            default:
                strAnimals = "animals";
                break;
            }
            
         // Erste Zeile
         Console.WriteLine ("Old Mac Donald had a farm - Ee i ee i o");
         // Zweite Zeile
         Console.WriteLine ("And on his farm he had some {0} - Ee i ee i o", strAnimals);
        
         // hier ist der Trick. Vom aktuellen Tier bis zum Hendl rueckwaerts zaehlen.        
         for (int nSound = nAnimal; nSound >= 0; nSound--)
            {
            string strSound;
            
            switch (nSound)
                {
                case 0:
                    strSound = "cluck";
                    break;
                case 1:
                    strSound = "moo";
                    break;
                case 2:
                    strSound = "oink";
                    break;
                case 3:
                    strSound = "woof";
                    break;
                case 4:
                    strSound = "meow";
                    break;
                case 5:
                    strSound = "baah";
                    break;
                case 6:
                    strSound = "neigh";
                    break;
                case 7:
                    strSound = "blub";
                    break;
                default:
                    strSound = "sound";
                    break;
                }

             // Dritte Zeile
             Console.WriteLine ("With a {0}-{0} here", strSound);
              // Vierte Zeile
             Console.WriteLine ("And a {0}-{0} there", strSound);
             // Fnfte Zeile
             Console.WriteLine ("Here a {0} there a {0}", strSound);
             // Sexte Zeile
             Console.WriteLine ("Everywhere a {0}-{0}", strSound);
             }
         // Letzte Zeile
        Console.WriteLine ("Old Mac Donald had a farm - Ee i ee i o\n");
        }
        
/***************************************************************************
********************** Variante mit Arrays *********************************
****************************************************************************/
      
      for (int nAnimal = 0; nAnimal < nNumAnimals; nAnimal++)
         {
         // Erste Zeile
         Console.WriteLine ("Old Mac Donald had a farm - Ee i ee i o");
         // Zweite Zeile
         Console.WriteLine ("And on his farm he had some {0} - Ee i ee i o", aszAnimals[nAnimal]);
        
         // hier ist der Trick. Vom aktuellen Tier bis zum Hendl rueckwaerts zaehlen.        
         for (int nSound = nAnimal; nSound >= 0; nSound--)
             {
             // Dritte Zeile
             Console.WriteLine ("With a {0}-{0} here", aszAnimalSounds[nSound]);
              // Vierte Zeile
             Console.WriteLine ("And a {0}-{0} there", aszAnimalSounds[nSound]);
             // Fnfte Zeile
             Console.WriteLine ("Here a {0} there a {0}", aszAnimalSounds[nSound]);
             // Sexte Zeile
             Console.WriteLine ("Everywhere a {0}-{0}", aszAnimalSounds[nSound]);
             }
         // Letzte Zeile
         Console.WriteLine ("Old Mac Donald had a farm - Ee i ee i o\n");
         }  
    }
}

syntax highlighted by Code2HTML, v. 0.9.1