DataRowCollection.Item[Int32] Propiedad

Definición

Obtiene la fila en el índice especificado.

public:
 property System::Data::DataRow ^ default[int] { System::Data::DataRow ^ get(int index); };
public System.Data.DataRow this[int index] { get; }
member this.Item(int) : System.Data.DataRow
Default Public ReadOnly Property Item(index As Integer) As DataRow

Parámetros

index
Int32

Índice de base cero de la fila que se va a devolver.

Valor de propiedad

Objeto DataRow especificado.

Excepciones

El valor de índice es mayor que el número de elementos de la colección.

Ejemplos

En el ejemplo siguiente se imprime el valor de la columna 1 de cada fila de un DataRowCollectionobjeto .

private void PrintRows(DataTable table)
{
    // Print the CompanyName column for every row using the index.
    for(int i = 0; i < table.Rows.Count; i++)
    {
        Console.WriteLine(table.Rows[i]["CompanyName"]);
    }
}
Private Sub PrintRows(table As DataTable)
     ' Print the first column for every row using the index.
     Dim i As Integer
     For i = 0 To table.Rows.Count - 1
         Console.WriteLine(table.Rows(i)(0))
     Next i
End Sub

Comentarios

Use el Contains método para determinar si existe un valor específico en la columna de clave de una fila.

Se aplica a

Consulte también