我的代码有问题,并说:编译器错误消息:CS1513:预期
for (int i = 2001; i<= 2017; i++)
{
for (int j = 1; j <= 12; j++)
{
thursday = LastThursdayOfTheMonth(j, i);
if (LStock.Any(element => element.date == thursday.ToString("dd-MMM-yyyy", dtf2)))
{
line = LStock.First(element => element.date == thursday.ToString("dd-MMM-yyyy", dtf2));
int index = LStock.IndexOf(line) - 1;
LFridays.Add(LStock.ElementAt(index));
}
else
{
while (LStock.Any(element => element.date == thursday.ToString("dd-MMM-yyyy", dtf2)) != true)
{
if (LStock.Any(element => element.date == thursday.ToString("dd-MMM-yyyy", dtf2)))
{
line = LStock.First(element => element.date == thursday.ToString(("dd-MMM-yyyy"), dtf2));
LFridays.Add(line);
}
else
{
thursday.AddDays(1);
}
}
}
else if (thursday.ToString("dd-MMM-yyyy",dtf2).Contains("25-dic"))
{
friday = LastFridayOfTheMonth(j, i);
bool find = false;
while (find != true )
{
if (LStock.Any(element => element.date == friday.ToString("dd-MMM-yyyy", dtf2)))
{
find = true;
line = LStock.First(element => element.date == friday.ToString("dd-MMM-yyyy", dtf2));
LFridays.Add(line);
}
else
{
friday = friday.AddDays(1);
}
}
}
}
}
我以为{}有问题,但是不可能找到它在哪里。有人可以找到我的{}较少还是其他错误?
非常感谢你
答案 0 :(得分:2)
我们真的应该拥有
if()
{
}
else
{
}
else if()
{
}
那不是
if()
{
}
else if()
{
}
else
{
}