The DataTable has two constructors:
public DataTable() public DataTable(string tableName)
The following examples construct an instance of a DataTable:
[VB] Dim workTable as DataTable workTable = New DataTable("Customer") workTable.CaseSensitive = false workTable.MinimumCapacity = 100 [C#] DataTable workTable = new DataTable("Customer"); workTable.CaseSensitive = false; workTable.MinimumCapacity = 100;
The first thing that we want to do in creating a DataTable instance is to set its name. The easiest way to do this is through the constructor. However, you could also simply set the name through the table object's TableName property.
DataTable worktable = new DataTable(); worktable.TableName = "Customers";
Additionally, we want to indicate whether the schema that adds to the table should be case sensitive or not. If you set the case sensitive property to true, this will affect string comparisons in sorting, searching, and filtering.
Setting the Minimum Capacity property enables the system to create an initial set of rows that will help to optimize performance.