Return to Snippet

Revision: 37703
at December 15, 2010 12:54 by dotNetkow


Updated Code
string result = string.Empty;

List<int> listOfInts = new List<int>();
foreach (int number in listOfInts)
{
   if (number == listOfInts.Last())
   {
      result += number;
   }
   else
   {
      result += string.format("{0},", number);
   }
}

Revision: 37702
at December 15, 2010 12:51 by dotNetkow


Initial Code
List<int> listOfInts = new List<int>();
foreach (int number in listOfInts)
{
   if (number == listOfInts.Last())
   {
      result += number;
   }
   else
   {
      result += string.format("{0},", number);
   }
}

Initial URL


Initial Description


Initial Title
Create a comma-delimited list from IEnumerable

Initial Tags
c#

Initial Language
C#