DataRowCollection.Item[Int32] 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得指定索引的該列。
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 方法判斷某列的鍵欄位是否存在特定值。