/ Published in: C#
Expand |
Embed | Plain Text
string result = string.Empty; foreach (int number in listOfInts) { if (number == listOfInts.Last()) { result += number; } else { result += string.format("{0},", number); } }
Comments
Subscribe to comments
You need to login to post a comment.

I think that using a
StringBuilderis more efficient here.There would be a problem if the last number also appears anywhere else in the list.