<?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: ToDelimitedString Extension Method</title>
	<atom:link href="http://elegantcode.com/2008/10/02/todelimitedstring-extension-method/feed/" rel="self" type="application/rss+xml" />
	<link>http://elegantcode.com/2008/10/02/todelimitedstring-extension-method/</link>
	<description></description>
	<lastBuildDate>Wed, 17 Mar 2010 08:54:42 -0500</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Chris Brandsma</title>
		<link>http://elegantcode.com/2008/10/02/todelimitedstring-extension-method/comment-page-1/#comment-34295</link>
		<dc:creator>Chris Brandsma</dc:creator>
		<pubDate>Fri, 03 Oct 2008 17:15:00 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2008/10/02/todelimitedstring-extension-method/#comment-34295</guid>
		<description>public static string QuickFormat(this string format, params object[] args )
{
	return string.Format(format, args);
}</description>
		<content:encoded><![CDATA[<p>public static string QuickFormat(this string format, params object[] args )<br />
{<br />
	return string.Format(format, args);<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Brandsma</title>
		<link>http://elegantcode.com/2008/10/02/todelimitedstring-extension-method/comment-page-1/#comment-34293</link>
		<dc:creator>Chris Brandsma</dc:creator>
		<pubDate>Fri, 03 Oct 2008 17:12:59 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2008/10/02/todelimitedstring-extension-method/#comment-34293</guid>
		<description>@tobin: ok, I really like the idea of the quick format.  I have to do that one now.</description>
		<content:encoded><![CDATA[<p>@tobin: ok, I really like the idea of the quick format.  I have to do that one now.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tobin Harris</title>
		<link>http://elegantcode.com/2008/10/02/todelimitedstring-extension-method/comment-page-1/#comment-34216</link>
		<dc:creator>Tobin Harris</dc:creator>
		<pubDate>Fri, 03 Oct 2008 09:01:53 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2008/10/02/todelimitedstring-extension-method/#comment-34216</guid>
		<description>Doh! After posting I saw the previous comment mentioned all this. Soz.</description>
		<content:encoded><![CDATA[<p>Doh! After posting I saw the previous comment mentioned all this. Soz.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tobin Harris</title>
		<link>http://elegantcode.com/2008/10/02/todelimitedstring-extension-method/comment-page-1/#comment-34215</link>
		<dc:creator>Tobin Harris</dc:creator>
		<pubDate>Fri, 03 Oct 2008 09:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2008/10/02/todelimitedstring-extension-method/#comment-34215</guid>
		<description>I like the idea of that. What about this (off top of head):

    public class Customer
    {
       //...properties
       public string FullName{ get{ return String.Format(&quot;{0} {1}&quot;, FirstName, LastName; } } 
    }

    string result = string.Join(&quot;,&quot;, customers.Select(c=&gt;c.FullName).ToArray() );

Something like that, anyway. Or if you don&#039;t like FulllName, would this work?

    string result = string.Join(&quot;,&quot;, customers.Select(c=&gt;String.Format(&quot;{0} {1}&quot;, c.FirstName, c.LastName  ).ToArray() );

I also write an extension method for string to make String.Format more fluent. You can then do this:

   string fullName = &quot;{0} {1}&quot;.QuickFormat(c.Forename, c.Surname);</description>
		<content:encoded><![CDATA[<p>I like the idea of that. What about this (off top of head):</p>
<p>    public class Customer<br />
    {<br />
       //&#8230;properties<br />
       public string FullName{ get{ return String.Format(&#8221;{0} {1}&#8221;, FirstName, LastName; } }<br />
    }</p>
<p>    string result = string.Join(&#8221;,&#8221;, customers.Select(c=&gt;c.FullName).ToArray() );</p>
<p>Something like that, anyway. Or if you don&#8217;t like FulllName, would this work?</p>
<p>    string result = string.Join(&#8221;,&#8221;, customers.Select(c=&gt;String.Format(&#8221;{0} {1}&#8221;, c.FirstName, c.LastName  ).ToArray() );</p>
<p>I also write an extension method for string to make String.Format more fluent. You can then do this:</p>
<p>   string fullName = &#8220;{0} {1}&#8221;.QuickFormat(c.Forename, c.Surname);</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Brandsma</title>
		<link>http://elegantcode.com/2008/10/02/todelimitedstring-extension-method/comment-page-1/#comment-34203</link>
		<dc:creator>Chris Brandsma</dc:creator>
		<pubDate>Fri, 03 Oct 2008 07:31:17 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2008/10/02/todelimitedstring-extension-method/#comment-34203</guid>
		<description>@Terry: I forgot about Func (I remembered Action, but forgot about Func).  OK, fixed my code, retested, still works.  Thank you for the suggestion.

@Steve: Missed the delimiter.Length, thank you.  

I looked at string.Join, and the reason I shyed away from it was because of the ToArray.  The ToArray is unlikely to cause problems, but it is slightly more direct in that a separate array does not have to be created.

Which, for the size of the data that I&#039;m parsing, is probably being offset by the use of the StringBuilder.

This is what I get for posting something so quickly...but then again, it is a great way to learn/remember what is possible.</description>
		<content:encoded><![CDATA[<p>@Terry: I forgot about Func (I remembered Action, but forgot about Func).  OK, fixed my code, retested, still works.  Thank you for the suggestion.</p>
<p>@Steve: Missed the delimiter.Length, thank you.  </p>
<p>I looked at string.Join, and the reason I shyed away from it was because of the ToArray.  The ToArray is unlikely to cause problems, but it is slightly more direct in that a separate array does not have to be created.</p>
<p>Which, for the size of the data that I&#8217;m parsing, is probably being offset by the use of the StringBuilder.</p>
<p>This is what I get for posting something so quickly&#8230;but then again, it is a great way to learn/remember what is possible.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve</title>
		<link>http://elegantcode.com/2008/10/02/todelimitedstring-extension-method/comment-page-1/#comment-34195</link>
		<dc:creator>Steve</dc:creator>
		<pubDate>Fri, 03 Oct 2008 07:04:49 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2008/10/02/todelimitedstring-extension-method/#comment-34195</guid>
		<description>sb.Remove(sb.Length - 1, 1); should be
sb.Remove(sb.Length - delimiter.Length, delimiter.Length);

And I always use the string.Join method, first argument is your delimiter, second argument is a string array.
return string.Join(delimiter, list.Select(action).ToArray());</description>
		<content:encoded><![CDATA[<p>sb.Remove(sb.Length &#8211; 1, 1); should be<br />
sb.Remove(sb.Length &#8211; delimiter.Length, delimiter.Length);</p>
<p>And I always use the string.Join method, first argument is your delimiter, second argument is a string array.<br />
return string.Join(delimiter, list.Select(action).ToArray());</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Terry Hughes</title>
		<link>http://elegantcode.com/2008/10/02/todelimitedstring-extension-method/comment-page-1/#comment-34178</link>
		<dc:creator>Terry Hughes</dc:creator>
		<pubDate>Fri, 03 Oct 2008 04:59:27 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2008/10/02/todelimitedstring-extension-method/#comment-34178</guid>
		<description>Hey, it ate my signs ...

Func should really be Func&lt;T, string&gt;
And in case that didn&#039;t work a Func that takes a T and returns a string.</description>
		<content:encoded><![CDATA[<p>Hey, it ate my signs &#8230;</p>
<p>Func should really be Func&lt;T, string&gt;<br />
And in case that didn&#8217;t work a Func that takes a T and returns a string.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Terry Hughes</title>
		<link>http://elegantcode.com/2008/10/02/todelimitedstring-extension-method/comment-page-1/#comment-34177</link>
		<dc:creator>Terry Hughes</dc:creator>
		<pubDate>Fri, 03 Oct 2008 04:55:13 +0000</pubDate>
		<guid isPermaLink="false">http://elegantcode.com/2008/10/02/todelimitedstring-extension-method/#comment-34177</guid>
		<description>Chris,

I&#039;m curious as to why do you use a custom delegate when you can use a Func? Also, is there a reason for action.Invoke(t) rather than action(t)?

Terry</description>
		<content:encoded><![CDATA[<p>Chris,</p>
<p>I&#8217;m curious as to why do you use a custom delegate when you can use a Func? Also, is there a reason for action.Invoke(t) rather than action(t)?</p>
<p>Terry</p>
]]></content:encoded>
	</item>
</channel>
</rss>
