I want the function PrintMaanden() to print every month with its string, e.g. "1 => January" Instead the function prints just the month itself, e.g. "January".
What did I do wrong here? Note that for this code I have to use the other function (that does work correctly as it is) PrintMaand() in the function PrintMaanden().
static void Main(string[] args)
{
Program kalenderMaand = new Program();
kalenderMaand.Start();
}
void Start()
{
//New object month of type Month (class Month)
Maanden maand;
maand = new Maanden();
PrintMaanden();
PrintMaand(maand);
//Read number of the month
Console.Write("Typ het nummer van de maand: ");
string month = Console.ReadLine();
Maanden monthNumber = (Maanden)int.Parse(month);
//Display the month based on the number that was typed
switch (monthNumber)
{
case Maanden.Januari:
Console.WriteLine("1 => Januari");
break;
case Maanden.Februari:
Console.WriteLine("2 => Februari");
break;
case Maanden.Maart:
Console.WriteLine("3 => Maart");
break;
case Maanden.April:
Console.WriteLine("4 => April");
break;
case Maanden.Mei:
Console.WriteLine("5 => Mei");
break;
case Maanden.Juni:
Console.WriteLine("6 => Juni");
break;
case Maanden.Juli:
Console.WriteLine("7 => Juli");
break;
case Maanden.Augustus:
Console.WriteLine("8 => Augustus");
break;
case Maanden.September:
Console.WriteLine("9 => September");
break;
case Maanden.Oktober:
Console.WriteLine("10 => Oktober");
break;
case Maanden.November:
Console.WriteLine("11 => November");
break;
case Maanden.December:
Console.WriteLine("12 => December");
break;
}
Console.ReadKey();
}
void PrintMaand(Maanden maand)
{
Console.WriteLine(maand);
}
void PrintMaanden()
{
for (int i = 1; i < 13; i++)
{
PrintMaand((Maanden) i);
}
}