<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Converting IEnumerable to a Comma-Delimited String</title>
	<atom:link href="http://underground.infovark.com/2008/09/02/converting-ienumerable-to-a-comma-delimited-string/feed/" rel="self" type="application/rss+xml" />
	<link>http://underground.infovark.com/2008/09/02/converting-ienumerable-to-a-comma-delimited-string/</link>
	<description>The Infovark technology blog</description>
	<lastBuildDate>Fri, 19 Feb 2010 02:24:24 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Steve Cooper</title>
		<link>http://underground.infovark.com/2008/09/02/converting-ienumerable-to-a-comma-delimited-string/comment-page-1/#comment-82</link>
		<dc:creator>Steve Cooper</dc:creator>
		<pubDate>Tue, 02 Sep 2008 21:59:06 +0000</pubDate>
		<guid isPermaLink="false">http://underground.infovark.com/?p=107#comment-82</guid>
		<description>Hi. Thanks for the mention! I&#039;ve found that Join is so useful on IEnumerable, I&#039;ve written an extension function which has this signature;

    string Join(this IEnumerable sequence, string seperator);

which means you can write;
    
    string delimitedids = ids.Select(x =&gt; x.ToString()).Join(&quot;, &quot;);

Here&#039;s the implementation using a stringbuilder;
    
    public static string Join(this IEnumerable strings, string seperator)
    {
        IEnumerator en = strings.GetEnumerator();
        StringBuilder sb = new StringBuilder();
        if (en.MoveNext())
        {
            // we have at least one item. 
            sb.Append(en.Current);
        }
        while (en.MoveNext())
        {
            // second and subsequent get delimiter
            sb.Append(seperator).Append(en.Current);
        }
        return sb.ToString();
    }

I tend to use this all the time when putting together code that generates descriptions; debug messages, ToStrings, that kind of thing.</description>
		<content:encoded><![CDATA[<p>Hi. Thanks for the mention! I&#8217;ve found that Join is so useful on IEnumerable, I&#8217;ve written an extension function which has this signature;</p>
<p>    string Join(this IEnumerable sequence, string seperator);</p>
<p>which means you can write;</p>
<p>    string delimitedids = ids.Select(x =&gt; x.ToString()).Join(&#8220;, &#8220;);</p>
<p>Here&#8217;s the implementation using a stringbuilder;</p>
<p>    public static string Join(this IEnumerable strings, string seperator)<br />
    {<br />
        IEnumerator en = strings.GetEnumerator();<br />
        StringBuilder sb = new StringBuilder();<br />
        if (en.MoveNext())<br />
        {<br />
            // we have at least one item.<br />
            sb.Append(en.Current);<br />
        }<br />
        while (en.MoveNext())<br />
        {<br />
            // second and subsequent get delimiter<br />
            sb.Append(seperator).Append(en.Current);<br />
        }<br />
        return sb.ToString();<br />
    }</p>
<p>I tend to use this all the time when putting together code that generates descriptions; debug messages, ToStrings, that kind of thing.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
