Return to Snippet

Revision: 4737
at January 18, 2008 15:42 by ecavazos


Initial Code
string str = "";

// loop though an array and create a string
// delimited with commas
foreach (string s in fieldNames)
{
    str += s;

    // if this not the last item in the array
    // append a comma to end of the string.
    if (s != fieldNames[fieldNames.Length - 1])
    {
        str += ", ";
    }
}

Initial URL

                                

Initial Description
This can be useful for string preparations.

Initial Title
Merging a String Array to a Comma delimited String (foreach)

Initial Tags
array

Initial Language
C#