I have tried to make the following array dynamic but ran into a 'problem'. The datatable below has 4 items.
int[] refNos = new int[100];
for (int i = 0; i < newTable2.Rows.Count; i++)
{
refNos[i] = System.Convert.ToInt32(newTable2.Rows[i][1]);
}
When I display refNos[i] I get all items, however if I use an array list instead I get 3 items. The last item is not displayed ?
ArrayList refNos = new ArrayList();
for (int i = 0; i < newTable2.Rows.Count; i++)
{
refNos1.Add(System.Convert.ToInt32(newTable2.Rows[i][1]));
}
This does not display the last item. Why ?
I would really like to make this dynamic but I can't get through ?
Loading
MartoPosted Jun 23, 2008, 9:40 AM
How should I use the arraylist to obtain the values of a column in a datatable ?
Mike GoldPosted Jun 20, 2008, 2:01 PM
Hi Marto,
I've been using ArrayList for quite some time, and there is nothing wrong with it.
You can step through the for loop and examine the items as each one is inserted. Make sure you step past the line that is adding it. You should see the first item added, then the next, then the next. This will help you discover your problem.