Months and Seasons
The switch/case block is embedded inside the loop
Months and Seasons
The switch/case block is embedded inside the loop
The switch/case block is embedded inside the loop
private void Form1_Load(object sender, EventArgs e)
{
//Add months and seasons to list box
string season="Winter";
for (int mth = 1; mth <= 12; mth++)
{
switch (mth)
{
case 1: season = "Winter"; break;
case 3: season = "Spring"; break;
case 6: season = "Summer"; break;
case 9: season = "Fall"; break;
case 12: season = "Winter"; break;
}
lstMonths.Items.Add(mth + ": " + season);
}
}