DataRowCollection.Item[Int32] 屬性

定義

取得在指定索引處的資料列。

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

參數

index
Int32

要傳回之資料列的以零起始的索引。

屬性值

指定的 DataRow

例外狀況

索引值大於集合中項目的數目。

範例

下列範例會列印 中 DataRowCollection 每個資料列第 1 欄的值。

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

備註

Contains使用 方法來判斷資料列索引鍵資料行中是否有特定值。

適用於

另請參閱