我只需要一些指導我如何顯示當月秋季當天的日期。例如,如果用戶在當月的星期一和31天輸入0,則它將顯示所有星期幾和當月星期幾對應的日期?感謝我迄今爲止的這一點,但它似乎不適用於用戶輸入。C#二維數組日曆日月
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Calendar
{
class Program
{
static int startDay = new int();
static int totalDays = new int();
static void Main(string[] args)
{
Console.Write("Enter the day the first falls on (Mon = 0, etc): ");
startDay = Convert.ToInt32(Console.ReadLine());
Console.Write("How many days in the month? ");
totalDays = Convert.ToInt32(Console.ReadLine());
}
public static List<DateTime> getDates()
{
List<DateTime> lstSundays = new List<DateTime>();
int intMonth = DateTime.Now.Month;
int intYear = DateTime.Now.Year;
int intDaysThisMonth = DateTime.DaysInMonth(intYear, intMonth);
DateTime oBeginnngOfThisMonth = new DateTime(intYear, intMonth, 1);
for (int i = 1; i < intDaysThisMonth + 1; i++)
{
if (oBeginnngOfThisMonth.AddDays(i).DayOfWeek == DayOfWeek.Sunday)
{
lstSundays.Add(new DateTime(intYear, intMonth, i));
}
}
return lstSundays;
}
}
}
歡迎來到Stack Overflow。請將代碼*作爲文本發佈*而不是圖片,並且您的要求太模糊,目前我們無法幫助您。請閱讀https://codeblog.jonskeet.uk/2010/08/29/writing-the-perfect-question/並記住Stack Overflow的目標是創建一個高質量問題和答案的存儲庫。 –
嗯...我不認爲創建一個新的配置文件並再次提出相同的問題,首先向您指出的信息缺乏完全相同的信息,將會有所幫助。 http://stackoverflow.com/questions/40869698/c-sharp-2d-arrays-calendar-month –
我正要發佈相同的東西。將此添加到您的問題'該計劃應該要求您在一個月中的第一天(0到6之間)以及該月有多少天的一週中的某一天。它也應該要求這個月的名字。「你如何期待幫助?人們不能讀你的想法 –