Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to read a specific row of data into an array. I know how to get my excel file to read but i do not know how to get a specific row into an array....Please help me understand how to declare a dynamic array! I am currently trying to use a List but I am struggling to convert it to an array. (The row contains numbers)
Posted
Comments
Maciej Los 17-Jun-15 13:54pm    
What have you tried? Where are you stuck?

As per my understanding you wants to convert
List<DataRow> to List of array

In that case you can follow the below two ways
var lst = new List<datarow>();

1. using LINQ
List<object[]> lstObj = lst.Select((x) => x.ItemArray).ToList();

2. using foreach
var lstobj = new List<object[]>();
     foreach (DataRow drTemp in lst)
     lstobj.Add(drTemp.ItemArray);




Suppose if you want to convert from
List<DataRow>
to complete array, then you can follow the below code
var newobj = lst.Select((x) => x.ItemArray).ToArray();
 
Share this answer
 
v3
Have a look here: List<t>.ToArray Method[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900