System.Data Namespace DataTableCollection Class
Returns the index of a specified DataTable object.
[ VB ]
Overloads Overridable Public Function IndexOf ( _
ByVal table As DataTable _
) As Integer
[ C# ]
public virtual int IndexOf (
DataTable table
);
[ C++ ]
public: virtual int IndexOf (
DataTable* table
);
[ JScript ]
public function IndexOf (
table : DataTable
) : int;
- table
- The DataTable to find.
The index of the DataTable if it is in the collection; otherwise, -1.
Use the IndexOf method to determine the index of a given table.
Before calling IndexOf, you can test for the existence of a table by using the Contains method.
The following example returns the index of each table in a DataTableCollection.
private void GetIndexes ( DataSet ds ) {
DataTableCollection myTables = ds.Tables;
// get the index of each table in the collection.
foreach ( DataTable tbl in myTables ) {
Response.Write ( myTables.IndexOf ( tbl ) );
}
}
Private Sub GetIndexes ( ByVal ds As DataSet )
Dim myTables As DataTableCollection = ds.Tables
Dim tbl As DataTable
' get the index of each table in the collection.
For Each tbl In myTables
Response.Write ( myTables.IndexOf ( tbl ) )
Next
End Sub |
|
C# |
VB |
DataTableCollection Members DataTableCollection.IndexOf Overload List Contains