I'm trying to cycle through strings in a list with a foreach loop, but I don't know how to change the item that's being referenced - How can I change s
in the list... e.g. below I want to add "-" to the end of every string, s
in myStringList
foreach(string s in myStringList)
{
s = s + "-";
}
I can't do things to s because it's a "foreach iteration variable" - so can I not change it as I cycle through?
Do I have to use an int
to count through?
I'm sure there's a simpler way...