Re: Slicing Routine!

Tech-Archive recommends: Fix windows errors by optimizing your registry



So whenever you get a 2 or a 1 you start a new bundle?

Just if statement it then a bit like this, very rough code:

foreach(int i in arr1)
{
if ( i>0 && i <= 2)
{
//check string array if its empty make a new one
//if it isnt add it to array and start new one
//add 1 or 2 to string array
}
else
{
//concat to string array all numbers after 1 or 2
}
}

return completeStringArray;

"Vai2000" <nospam@xxxxxxxxxxxxx> wrote in message
news:%23qmuSA8QHHA.2252@xxxxxxxxxxxxxxxxxxxxxxx
Hi All, I am looking for a smart solution to accomplish this task (.net
1.0)
Appreciate your input

I have a group of numbers in an arrayList
2,3,5,2,1,2,2

I need to output them into groups of
2,3,5
2
1
2
2

basically whenever I encounter 1 or 2 I bundle them up..

The numbers are in an arrayList, and I output them as string []

Arraylist Bundle(Arraylist)
{
// arr1 will contain (2,3,5)
alReturn.Add(arr1);
..................
return alReturn
}

TIA




.