本文介绍了休息后恢复foreach的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的代码如下:
My code is as follow:
private void IzvadaJautajumuAtbildes()
{
var something =
from x in channel2.GetJautajumuSaraksts(SelectedTestID)
select new
{
id = x.QuestionID, ; //1,2,4,5,7
name = x.Name
};
foreach (var i in something)
{
lblQuestion.Text = i.nosauk;
currentQuestionID = i.id
answer = channel2.GetAnswer(currenQuestionID);
foreach (var i2 in answer)
{
btnAtbilde1.Text = i2.Answer1;
btnAtbilde2.Text = i2.Answer2;
btnAtbilde3.Text = i2.Answer3;
btnAtbilde4.Text = i2.Answer4;
}
break;
}
}
在此代码中,在button2_Click
事件上,当我单击一次button2
时,一切正常,我收到了问题&答案.
如何再次迭代IzvadaJautajumuAtbildes()
,但使用下一个ID.
2不是1.
In this code, on button2_Click
event, when I click on button2
once, everything is ok, I get question & answers.
How can I iterate IzvadaJautajumuAtbildes()
again, but with the next id.
2 not 1.
推荐答案
private void IzvadaJautajumuAtbildes(int[] testValues)
{
for (int i = 0; i < testValues.Length(0); i++)
{
var something =
from x in channel2.GetJautajumuSaraksts(testValues[i])
..................
// rest of your code here
..................
break;
}
}
}
检查语法,这是我的头上事情.
Check syntax, I''m doing this off the top of my head.
这篇关于休息后恢复foreach的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!