0

I am trying to populate an ArrayList using the elements from a DataTable. I know I could do this using Loop, but I am trying to figure out how to using AddRange.

Here's my code:

SomeArrayList.AddRange(SomeDataTable.Rows.Item(0).ItemArray)

The problem is that I can pass the collection except for the Zeroth element.

This is the collection I am trying to pass to the ArrayList:
1. Dog
2. Cat
3. Bird

This is what I got
1. Cat
2. Bird

2
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by Luc001
0

Hi,

You can use the AddRange method to do so.
For more explanation, look here.

Hi,

I've already used the AddRange, and it works(barely). My Question still stands: Why does the Index 0 of the collection SomeDataTable.Rows.Item(0).ItemArray is not present in the SomeArrayList.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.