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: To find the value of column D, for a given combination of values for column A, B and C.
I guess looping over the set of data rows should do it. Is there a way to use Datatable.Select() to accomplish this? To be more specific – can I have multiple conditions in the select filter i.e. a logical AND operator connecting conditions for each of the columns A, B and C.
Yes, the
DataTable.Selectmethod supports boolean operators in the same way that you would use them in a “real” SQL statement:See DataColumn.Expression in MSDN for the syntax supported by DataTable’s
Selectmethod.