views:

349

answers:

2

Is there a trade off in respect to performance, trade off in respect to memory consumption?

+7  A: 

Yes, absolutely a DataTable consumes more memory than a List.

The DataTable class has lots of objects for column definitions, the table info (name, etc), collections of row objects, the "item arrays" for each row (which is basically all the List would have), etc.

EDIT: Also, List is more performant for adding items, itterating through, etc. (reflect the code for "Add" for generic lists, and for data tables to see more detail).

Timothy Khouri
+2  A: 

Oh yeah, it's fat. It can be much more efficient than List<> though. It creates an index so lookups can be O(1). Rows are stored in a red-black tree so inserts and deletes can be O(log n). All these operations are O(n) for List<>. To get this kind of perf, you'll have to choose your columns and queries wisely though. Same kind of considerations as a regular database table.

Hans Passant