Suppose you have a DataTable having 100,000 rows and 50 columns. Now you've create array of perticular column values, how will you do that?

 Posted by Hmanjarawala on 12/7/2011 | Category: .NET Framework Interview questions | Views: 4506 | Points: 40

It's simple.
for C#
object[] arr = Array.ConvertAll<DataRow, object>(dataTable.Select(<criteria if any or leave blank>), (DataRow r) => r[<column-name>]);

for VB
dim arr as Object() = Array.ConvertAll(Of DataRow, Object)(dataTable.Select(<criteria if any or leave blank>), Function(r as DataRow) r(<column-name>));

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response

More Interview Questions by Hmanjarawala