Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 创建定期预订时出现语法错误_C#_Sql_Database_Visual Studio 2010 - Fatal编程技术网

C# 创建定期预订时出现语法错误

C# 创建定期预订时出现语法错误,c#,sql,database,visual-studio-2010,C#,Sql,Database,Visual Studio 2010,我试图用下面的代码创建一个重复的预订,但是我遇到了错误,我该如何修复这个代码 //creates a recurring booking if (repeats_check.IsChecked == true) { DateTime date0=date_picker.SelectedDate; //Calculates the total number of days between each repeat by m

我试图用下面的代码创建一个重复的预订,但是我遇到了错误,我该如何修复这个代码

//creates a recurring booking
            if (repeats_check.IsChecked == true)
            {
               DateTime date0=date_picker.SelectedDate;
//Calculates the total number of days between each repeat by multiplying the number of weeks by 7.
                int Rdays1 = Rdays + (Rweeks * 7);
                for (int i = 1; i <= occurences.Value; i++)
                {
                   DateTime Date(i) = Date(i-1).AddDays(Rdays1);
                   DateTime Datei = Datei.AddMonths(Rmonths);

                }

            }
//创建定期预订
if(重复检查。IsChecked==true)
{
DateTime date0=日期\u选取器.SelectedDate;
//将周数乘以7,计算每次重复之间的总天数。
int Rdays1=Rdays+(每周两次*7);

对于(int i=1;i不确定您想在这里做什么:

DateTime Date(i) = Date(i-1).AddDays(Rdays1);
DateTime Datei = Datei.AddMonths(Rmonths);
它肯定不起作用。如果它是数组,则使用日期[i]。但在第一行中,日期[i]不需要键入。您能澄清一下代码吗

编辑:

按照你的解释:

DateTime[] dates = new DateTime[occurences.Value+1];
dates[0] = date_picker.SelectedDate;
for (int i = 1; i <= occurences.Value; i++)
  dates[i] = dates[i-1].AddDays(Rdays1).AddMonths(Rmonths);
DateTime[]dates=newdatetime[occurrences.Value+1];
日期[0]=日期\u选取者。选择日期;

对于(int i=1;i它报告了什么错误?应为;或=(无法在声明中指定构造函数参数)抱歉,实际上,作为一个VB用户,我比我想象的要迷失一些:)…它需要一个C#标记(我已经更改了它).Good LuckI想创建一个重复预订,其中Rdays是重复预订的天数,Rweeks是重复预订的周数,Rmonths是重复预订的月数。我有一定数量的重复预订,所以我有一个for循环用于重复预订。我想要日期(I)使用for循环中的数字表示日期,日期(i-1)表示前一个日期。因此,当i=1时,日期(1)=日期(0)。在C#表示法中,AddDays(Rdays1)表示数组不起作用,请使用[1]但是首先创建它。那么您建议如何在我的场景中执行此操作呢?我得到的索引超出了这一行的数组错误范围:dates[i]=dates[i-1]。AddDays(Rdays1);是的,我没有注意到您正在使用