C# How to place a comma after each word but the last in the list
Posted
by
user576712
on Stack Overflow
See other posts from Stack Overflow
or by user576712
Published on 2011-01-15T12:48:41Z
Indexed on
2011/01/15
12:53 UTC
Read the original article
Hit count: 189
c#
I totally new to C# and learning as I go. I am stuck on issue which I'm hoping an experienced programmer can help. I have added a CheckedListBox to my form and added a collection of 6 items to it. I need all but the last item selected to have a comma placed beside it, so my question is: how can I tell C# NOT to place a comma beside the last item selected?
foreach (object itemChecked in RolesCheckedListBox.CheckedItems)
{
sw.Write(itemChecked.ToString() + ",");
}
Thanks for any help received! Dan
© Stack Overflow or respective owner