Checks whether the collection has a column at the specified index.
[Visual Basic] Overloads Public Function Contains( _ ByVal index As Integer _ ) As Boolean [C#] public bool Contains( int index ); [C++] public: bool Contains( int index ); [JScript] public function Contains( index : int ) : Boolean;
true if a column exists at this index; otherwise, false.
The Contains method can confirm the existence of a column before performing further operations on the column.
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.
[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 | ColumnsCollection.Contains Overload List | CanRemove | IndexOf