将foreach循环转换为linq代码

3 c# linq

下面的代码按预期工作,但我想转换下面的代码使用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...
                    }
                }
           }
Run Code Online (Sandbox Code Playgroud)

Ofe*_*lig 5

foreach (string match in selections.Where(match => checkboxName == match.Trim()))
{
    //matched... do more work here...
}
Run Code Online (Sandbox Code Playgroud)