Repeat loop with paired and sequential output

3

How can I generate this list in sequential pairs:

Array = Itens.text.Split(","[0]);
int qnt = Array .Length;

    for (int i = 0; i < qnt; i++) 
    {
        TextBox.Text = Array[i].text;
        i++;
        TextBox.Text = Array[i].text;               
    }

This way it does not work, plus your remove i++ the output is like this:

TextBox.text = Array[0];
TextBox.text = Array[0]; 

TextBox.text = Array[1];
TextBox.text = Array[1]; 

TextBox.text = Array[2];
TextBox.text = Array[2]; 

I wanted the output to look like this:

TextBox.text = Array[0];
TextBox.text = Array[1]; 

TextBox.text = Array[2];
TextBox.text = Array[3]; 

TextBox.text = Array[4];
TextBox.text = Array[5]; 

and etc, every loop it rotate me that way. If anyone can help me thank you!

    
asked by anonymous 30.07.2015 / 17:09

1 answer

2
Array = Itens.text.Split(","[0]);
int qnt = Array .Length;

    for (int i = 1; i < qnt; i += 2)
    {
        TextBox.Text = Array[i-1].text;
        TextBox.Text = Array[i].text;               
    }
    
30.07.2015 / 18:13