Datatable select with multiple conditions

前端 未结 7 1985
再見小時候
再見小時候 2020-12-02 17:03

I have a datatable with 4 columns A, B, C and D such that a particular combination of values for column A, B and C is unique in the datatable.

Objective:

7条回答
  •  清歌不尽
    2020-12-02 17:16

    Try this,
    I think ,this is one of the simple solutions.

    int rowIndex = table.Rows.IndexOf(table.Select("A = 'foo' AND B = 'bar' AND C = 'baz'")[0]);
    string strD= Convert.ToString(table.Rows[rowIndex]["D"]);
    

    Make sure,combination of values for column A, B and C is unique in the datatable.

提交回复
热议问题