DataTable.Select方法(String,String)

DataTable的Select方法,取得的是个Row数组,若要取其中的值,还需要再次for。

 

private void GetRowsByFilter()
{
    DataTable table = DataSet1.Tables["Orders"];

    string expression = "Date > '1/1/00'";
    string sortOrder = "CompanyName DESC";
    DataRow[] foundRows;

    foundRows = table.Select(expression, sortOrder);

    for(int i = 0; i < foundRows.Length; i ++)
    {
        Console.WriteLine(foundRows[i][0]);
    }
}

你可能感兴趣的:(select,Datatable)