DaneEdw
DaneEdw

Reputation: 446

Difference between Arrays and DataTables?

So I've been trying to better understand the difference between these two but all i can really find info on is the difference between DataSets and DataTables- a single Array can only hold one datatype, whereas from what i can tell, DataTables are basically a generic multidimensional array and it has a 1:1 relationship to the DataSource stored in memory. Is this accurate? are DataTables 'just' a generic multidimensional array or am i missing some fundamental difference?

Upvotes: 3

Views: 5725

Answers (2)

Oded
Oded

Reputation: 499132

A DataTable models a database table in memory. The type can track changes etc in order to sync with a database. The columns (dimensions) can be referenced either by index or name.

A DataSet can hold a collection of such tables and the relationships between them (referential integrity constraints).

An array doesn't do any of that.

Upvotes: 11

Reed Copsey
Reed Copsey

Reputation: 564641

DataTable is kind of like a multi-dimensional array in that it's an in-memory data storage of a certain "size", but there are significant additional features. For example, each "column" has name information and specific type information, there is change tracking for synchronization with the data storage, rows can store null values, etc..

A DataSet is basically an entire "set" of data (ie: multiple DataTables) held in memory.

Upvotes: 3

Related Questions