I have a datatable that contains a column as "Column-A". Now if that column contains a value of "Y" or "N", i need to set the count variable.
for that i need to check that if count is greater that 0 or not. How the same can be achieved with the help of LINQ?
Please guide!
Try this, it will count the number of rows that contain "Y" or "N" within Column-A
:
int count = dataTable.AsEnumerable()
.Count(row => row.Field<string>("Column-A") == "Y"
|| row.Field<string>("Column-A") == "N");
I think this is what you're trying to do? If I misunderstood your question, please let me know.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.