DataTable.Rows.Add() adds a row to the data table. However, how does it handle the underlying array?
When adding a single row at a time, does it rebuild the entire array with each row added?
Or is it able to simply modify the existing array without any hit on performance?
I am wondering if it’s better to determine the size of the array before filling it with data, or if somehow the data table is able to modify the collection without (behind the scenes) copying and moving things.
It’s my understanding that to adjust an array you have to redefine it and move previously existing data into the new structure.
My question is what is the work flow for the Collection.Add() method?
Take a look using software like DotPeek:
which calls:
which calls:
which calls:
which calls:
which calls one of those:
this.listis of typeDataRowCollection.DataRowTree, derived fromRBTree<DataRow>.RBTree<DataRow>andRBTreeNodeIdallows us to conclude that a Red-Black tree is being used!