I need to get a specific column header name based on value.
For ex: I am using the below query to get list of column headers and it works fine and on top of this can I get column names which has specific name like Department alone.
LINQ
string[] columnNames = dt.Columns.Cast<DataColumn>()
.Select(x => x.ColumnName)
.ToArray();
How can I add contains or exists to this query to get specific columns.
.Where(x => x == "Department")?xisDataColumn. How is that possible? Probably you mean.Where(x => x.ColumnName == "Name"). Check my answer.Select. I didn't answer this question because it's unclear and rather pointless to select a single string from a list of strings when you already have the string. I wish other people had thought the same...WhereafterSelectit works and I also have pointed this. I thought you said replaceSelectwithWhere.