Checks whether the collection contains a specified column.
Checks whether the collection contains a column with the specified name.
[Visual Basic] Overloads Public Function Contains(String) As Boolean
[C#] public bool Contains(String);
[C++] public: bool Contains(String*);
[JScript] public function Contains(String) : Boolean;
Checks whether the collection has a column at the specified index.
[Visual Basic] Overloads Public Function Contains(Integer) As Boolean
[C#] public bool Contains(int);
[C++] public: bool Contains(int);
[JScript] public function Contains(int) : Boolean;
The following example uses the Contains method and the CanRemove method to determine whether the column can be removed. If so, the column is removed.
Note This example shows how to use one of the overloaded versions of Contains. For other examples that may be available, see the individual overload topics.
[Visual Basic]
Dim cols As ColumnsCollection ' Get the ColumnsCollection from a DataTable in a DataSet. cols = DataSet1.Tables("Orders").Columns If cols.Contains(2) And cols.CanRemove(cols(2)) Then cols.Remove 2 End If
ColumnsCollection Class | ColumnsCollection Members | System.Data Namespace