views:

4521

answers:

2

What's the best performing way to convert a DataRowCollection instance to a DataRow[]?

+3  A: 

This is kind of obvious, but:

DataRowCollection.CopyTo(DataRow[] array, Int32 offset) ?

It seems like no matter what, you're going to have to iterate the collection (CopyTo iterates the internal DataRowTree elements).

I suppose you could use reflection to access the non-public tree, but at a significant cost.

Jared
+4  A: 
DataRow[] rows = dt.Select();

Assuming you still have access to the datatable.

Ely
Simplest answer, and correct. Should be marked as the accepted answer. This question now has 3,500 views!
Javaman59