Another Salesforce blog!!!

Salesforce, Apex

September, 2012

Extract substring from a string until finds a comma c#

substring = str.Split(‘,’)[0]; or You can use IndexOf() to find out where is the comma, and then extract the substring. If you are sure it will always have the comma you can skip the check.




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… } } […]