例外メッセージは次を返します。
Year、Month、および Day パラメーターは、表現できない DateTime を記述します。
例外がヒットしますmonthCalendar1.SelectionStart
DateTime check_date = monthCalendar1.SelectionStart;
for (int index = 0; index <= 5; index++)
{
check_date = new DateTime(check_date.Year, check_date.Month, check_date.Day - index);
}
私もこれを試しました。しかし、別の例外が発生しましたTargetInvocationException
DateTime check_date = monthCalendar1.SelectionStart;
for (int index = 0; index <= 5; index++)
{
check_date = check_date.AddDays(-index);
}
例外の詳細:
System.ArgumentOutOfRangeException は処理されませんでした Message=Year、Month、および Day パラメータは、表現できない DateTime を記述しています。Source=mscorlib StackTrace: System.DateTime.DateToTicks(Int32 年、Int32 月、Int32 日) で System.DateTime..ctor(Int32 年、Int32 月、Int32 日) で TestGetDates.Program.Main(String[] args) C:\Documents and Settings\ngd11\My Documents\Visual Studio 2010\Projects\TestGetDates\TestGetDates\Program.cs:System.AppDomain._nExecuteAssembly(アセンブリ アセンブリ、String[] args) の System.AppDomain.ExecuteAssembly の 15 行目System.Threading の System.Threading.ThreadHelper.ThreadStart_Context(Object state) の Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() で (String assemblyFile、Evidence assemblySecurity、String[] args)。