This is what I have. It will return the first cell with a non-null/empty text value – from any row besides the first. If those conditions aren’t met, it will return an empty set. Is there a more compact way of doing this that doesn’t require the second set of where/select clauses?
(Oh, and this is using a WatiN Table element…)
this.Lessors = lessorTable.OwnTableRows
.Where(row => row.Index > 0)
.Select(row => row.TableCells
.FirstOrDefault(cell =>
!string.IsNullOrEmpty(cell.Text) && cell.Text.Trim() != string.Empty))
.Where(cell => cell != null)
.Select(cell => cell.Text)
.ToList();
Introducing new range variable and usage of
String.IsNullOrWhiteSpacemethod can make your query more compact: