0
我試圖插入來自匹配()方法的4個值,一個接一個地插入4個不同的文本框,但無法設法從循環後逃脫將第一個值放入第一個文本框,這將使該值在第一個文本框中逐個出現,然後跳轉到下一個文本框以執行相同操作。這裏是我的代碼:?如何從匹配有或沒有foreach循環得到每個值
for (int g = 0; g <5; g++) //tried this inside foreach() ; no result
{
foreach (Match m in mc)
{
/////each foreach returns 4 value, which then should be feed to textbox13 to 16, one by one.
if (g == 1) { textBox13.Text = m.Groups[0].Value; MessageBox.Show(m.Groups[0].Value); continue; }
//but continue;'s are not breaking the loop
if (g == 2) { textBox14.Text = m.Groups[0].Value; MessageBox.Show(m.Groups[0].Value); continue; }
//all four value appears in the first textbox(textBox13), one by one, then jumps to 2nd textbox(textBox14) and does the same w/ the same values
////until the 4th textbox (textbox16)...
if (g == 3) { textBox15.Text = m.Groups[0].Value; MessageBox.Show(m.Groups[0].Value); continue; }
if (g == 4)
{
textBox16.Text = m.Groups[0].Value; MessageBox.Show(m.Groups[0].Value);
sendrow();
textBox13.Text = "";
textBox14.Text = "";
textBox15.Text = "";
textBox16.Text = "";
g = 0; // then all textboxes emptied for the next group of 4 values...
continue; //coming from a higher-loop, before the 1st for(), which is NOT shown here.
}
}
}
我在哪裏犯錯與foreach()循環有這場比賽,我們可以通過它們的索引挑選任何價值的,就像我們用它做它的一個特點。 Groups [index] .Value?
謝謝。