The solution 1 works for
ArrayList
also. Since, the
counter i
is incremented inside the for loop, I have put a little check to ensure that the loop does not throw error when the
arr.Length
(for array list
arr.Count
) is odd.
ArrayList arr = new ArrayList(){"12DBT183843IYP","950.00","12DBT183843YP","1137.00","Fifth"};
for(int i =0;i<arr.Count/2*2;i++)
{
Response.Write(string.Format("<tr><td>{0}</td><td>{1}</td></tr>\n",arr[i++], arr[i]));
}