DataRowCollection.Item 属性

获取指定索引处的行。

**命名空间:**System.Data
**程序集:**System.Data(在 system.data.dll 中)

语法

声明
Public ReadOnly Default Property Item ( _
    index As Integer _
) As DataRow
用法
Dim instance As DataRowCollection
Dim index As Integer
Dim value As DataRow

value = instance(index)
public DataRow this [
    int index
] { get; }
public:
property DataRow^ default [int] {
    DataRow^ get (int index);
}
/** @property */
public DataRow get_Item (int index)
JScript 支持使用索引属性,但不支持进行新的声明。

参数

  • index
    要返回的行的从零开始的索引。

属性值

指定的 DataRow

异常

异常类型 条件

IndexOutOfRangeException

索引值大于集合中项的数目。

备注

使用 Contains 方法确定特定值是否存在于行的键列中。

示例

下面的示例打印 DataRowCollection 中每一行的第一列的值。

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
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"]);
    }
}

平台

Windows 98、Windows 2000 SP4、Windows CE、Windows Millennium Edition、Windows Mobile for Pocket PC、Windows Mobile for Smartphone、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

.NET Compact Framework

受以下版本支持:2.0、1.0

请参见

参考

DataRowCollection 类
DataRowCollection 成员
System.Data 命名空间
Contains