Day: September 25, 2012

Convert foreach loop to Linq code

Converting this code to Linq: string[] selections = “Men,Women,Boys”.Split(‘,’); int _chkboxId = 0; int _chkboxTextId = 1; try { string id = “lstchk_” + _chkboxId; while (!driver.FindElement(By.Id(id)).Equals(null)) { string checkboxId = String.Format(“lstchk{0}”, _chkboxTextId); string checkboxName = driver.FindElement(By.Id(checkboxId)).Text; foreach (string match in selections) { if (checkboxName == match.Trim()) { //matched… do more work here… } } […]

Read more