【发布时间】:2013-07-17 03:32:11
【问题描述】:
我在这里有这段代码,基本上我在做一个 for 循环,因为我从数据库中检索记录(使用实体框架)但是当我想使用 if 语句进行比较时出现错误:
IList<Model.question> lstQuestion = qn.GetRecords(taskID, activityID);
for(int i = 0 ; i <lstQuestion.Count()-1 ; i++)
{
.... //code here
if(lstQuestion[i].QuestionNo == lstQuestion[i++].QuestionNo) // error at i++
{
tb.Text = lstQuestion[i++].QuestionContent;
sp1.Children.Add(tb);
}
我试过了
lstQuestion.Count() 代替 lstQuestion.Count()-1;
也不行。
QuestionNo 是我的数据库表中的一列。
完全错误:
当我删除整个 if 语句时,它工作正常。
【问题讨论】:
-
InnerException 说{“指定的视觉对象已经是另一个视觉对象的子对象或 CompositionTarget 的根。”}
标签: c# wpf entity-framework for-loop