TechNet
Export (0) Print
Expand All

DataTable.Select Method ()

 

Gets an array of all DataRow objects.

Namespace:   System.Data
Assembly:  System.Data (in System.Data.dll)

public DataRow[] Select()

Return Value

Type: System.Data.DataRow[]

An array of DataRow objects.

To ensure the proper sort order, specify sort criteria with Select or Select.

The following example returns an array of DataRow objects through the Select method.

private void GetRows()
{
    // Get the DataTable of a DataSet.
    DataTable table = DataSet1.Tables["Suppliers"];
    DataRow[] rows = table.Select();

    // Print the value one column of each DataRow.
    for(int i = 0; i < rows.Length ; i++)
    {
        Console.WriteLine(rows[i]["CompanyName"]);
    }
}

.NET Framework
Available since 1.1
Return to top
Show:
© 2016 Microsoft