Why I have got this result?
Code:
List<int> samba = new List<int>(new int[]
{1,2,0,0,0,0,3,2,1,
0,0,0,0,0,0,0,0,0,
});
foreach (int i in samba)
{
label1.Text += samba[i];
}
Result:
1201111002111111111
Perhaps you didn’t mean to print out the item at the index of the current item, but rather, but rather the current item:
The first time through your loop you’re printing out the item at position
1, which is2. The second time you’re printing out the item at position2, which is0. Then you print out the item at position0four times, and that’s1, etc.