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
2008-10-22 19:46:18
+4
A:
DataRow[] rows = dt.Select();
Assuming you still have access to the datatable.
Ely
2008-10-22 19:47:36
Simplest answer, and correct. Should be marked as the accepted answer. This question now has 3,500 views!
Javaman59
2010-06-28 23:31:20