Clear Method
Collapse the table of content
Expand the table of content

DataTableCollection.Clear Method ()

 

Clears the collection of all DataTable objects.

Namespace:   System.Data
Assembly:  System.Data (in System.Data.dll)

public void Clear()

To remove a particular DataTable from the collection, use the Remove method.

The following example gets the DataTableCollection of a DataSet, and then clears the collection of all tables.

private void ClearTables()
{
    // Get the DataSet of a DataGrid control.
    DataSet dataSet = (DataSet)DataGrid1.DataSource;
    DataTableCollection tables = dataSet.Tables;

    // Clear the collection.
    tables.Clear();
}

.NET Framework
Available since 1.1
Return to top
Show:
© 2016 Microsoft