C# 如何修复此类异常?ArgumentOutOfRange异常

C# 如何修复此类异常?ArgumentOutOfRange异常,c#,winforms,monthcalendar,C#,Winforms,Monthcalendar,异常消息返回: 年、月和日参数 描述一个不可表示的日期时间 异常会点击monthCalendar1。选择开始 DateTime check_date = monthCalendar1.SelectionStart; for (int index = 0; index <= 5; index++) { check_date = new DateTime(check_date.Year,

异常消息返回:

年、月和日参数 描述一个不可表示的日期时间

异常会点击
monthCalendar1。选择开始

            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);

            }
例外情况详情:

System.ArgumentOutOfRangeException未处理 Message=年、月和日参数描述不可表示的日期时间。 Source=mscorlib 堆栈跟踪: 在System.DateTime.DateToTicks(Int32年、Int32月、Int32天) 在System.DateTime..ctor(Int32年、Int32月、Int32天) 在C:\Documents and Settings\ngd11\My Documents\Visual Studio 2010\Projects\TestGetDates\TestGetDates\Program.Main(字符串[]args)中的TestGetDates.Program.Main处:第15行 位于System.AppDomain.\u nexecutestAssembly(程序集,字符串[]args) 位于System.AppDomain.ExecuteAssembly(字符串汇编文件、证据汇编安全性、字符串[]args) 在Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()上 位于System.Threading.ThreadHelper.ThreadStart\u上下文(对象状态) 在System.Threading.ExecutionContext.Run(ExecutionContext ExecutionContext,ContextCallback回调,对象状态) 位于System.Threading.ThreadHelper.ThreadStart()处 内部异常:


这可能会产生一个负数,导致此异常,请调试并检查其值。

谢谢您的回复。我将其更改为
AddDays(index)
,但会出现另一个异常,如targetInvocationException请提供更多信息I-e 1。你想要实现什么?2.异常堆栈跟踪(如果可以的话)没关系。:)我只是使用了一种不同的方法:)无论如何谢谢。我觉得,当使用自定义日期格式(如“MM/yyyy”)时,本机Win32 DateTimePicker中存在一个错误。请参见说明。还有一个解决办法
                DateTime check_date = monthCalendar1.SelectionStart;

                for (int index = 0; index <= 5; index++)
                {
                    check_date = check_date.AddDays(-index);

                }
  date_tax.Day - index