新手初学C#求大神解答,输出日历的方法要怎样写,我这样写该怎么改
public void Calendar(){
switch (_month)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
for (int i = 1; i <= 31; i++)
{
Console.Write(i + " ");
if (i % 7 == 0)
{
Console.WriteLine();
}
}
break;
case 4:
case 6:
case 9:
case 11:
for (int i = 1; i <= 30; i++)
{
Console.Write(i + " ");
if (i % 7 == 0)
{
Console.WriteLine();
}
}
break;
case 2:
if (_year % 4 == 0 && _year % 100 != 0 || _year % 400 == 0)
{
for (int i = 1; i <= 29; i++)
{
Console.Write(i + " ");
if (i % 7 == 0)
{
Console.WriteLine();
}
}
}
else
{
for (int i = 1; i <= 28; i++)
{
Console.Write(i + " ");
if (i % 7 == 0)
{
Console.WriteLine();
}
}
}
break;
}
}