DataTableCollection.Clear 方法

定義

清除所有 DataTable 物品的集合。

public:
 void Clear();
public void Clear();
member this.Clear : unit -> unit
Public Sub Clear ()

範例

以下範例取 DataTableCollectionDataSet,然後清除所有表的集合。

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

    // Clear the collection.
    tables.Clear();
}
Private Sub ClearTables()
   ' Get the DataSet of a DataGrid control.
   Dim dataSet As DataSet = CType(DataGrid1.DataSource, DataSet)
   Dim tables As DataTableCollection = dataSet.Tables

   ' Clear the collection.
   tables.Clear
End Sub

備註

要從集合中移除某個特定 DataTable 物件,請使用該 Remove 方法。

適用於