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 方法。

適用於