I'm using ADO.NET and C#, and I want to convert a DataTable object into an array of DataRows. What is an elegant way of doing this?
My first question would be why? The request makes no sense.
The answer is:
DataRow[] rows = myDataTable.Select();
Actually the DataTable has a property called Rows, witch provides the methods to do this.
You can accomplish this doing:
List<System.Data.DataRow> r = d.Rows.AsQueryable().OfType<System.Data.DataRow>().ToList();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With