Scarlett72
asked on
How to use string.join in method
I'm trying to create a method that returns a comma separated list of all Calendar controls on a page, the solutions I've read have suggested using string.join; however, I an confused on how to implement this. Could this also be an alternative solution?
protected String GetAllCalControls()
{
StringBuilder countCal = new StringBuilder();
foreach (Control ctrl in Page.Controls)
{
foreach (Control childc in ctrl.Controls)
{
if (childc is Calendar)
{
countCal.Append(childc.ID+",");
}
}
}
countCal.Remove(countCal.Length, -1);
return countCal.ToString();
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you it_saige, this is fantastic. I really need to play with it some more and read up on the concepts you've used to fully understand your solution.
Open in new window
Make sure you add using System.Linq if it is not already there.
-saige-