<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Eric Fickes &#187; implode</title>
	<atom:link href="http://ericfickes.com/tag/implode/feed/" rel="self" type="application/rss+xml" />
	<link>http://ericfickes.com</link>
	<description>Design minded Internet Programmer</description>
	<lastBuildDate>Fri, 28 Oct 2011 04:14:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Create a delimited list of SortedList Keys in C#</title>
		<link>http://ericfickes.com/2009/02/create-a-delimited-list-of-sortedlist-keys-in-c/</link>
		<comments>http://ericfickes.com/2009/02/create-a-delimited-list-of-sortedlist-keys-in-c/#comments</comments>
		<pubDate>Thu, 19 Feb 2009 22:39:53 +0000</pubDate>
		<dc:creator>Eric Fickes</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[implode]]></category>
		<category><![CDATA[SortedList]]></category>

		<guid isPermaLink="false">http://ericfickes.com/?p=486</guid>
		<description><![CDATA[I love C#, but miss the simplicity of PHP sometimes.  Specifically when dealing with collections.  Recently I ran into a situation where PHP&#8217;s implode would have been perfect, but I wasn&#8217;t able to find any quick and easy built in &#8230; <a href="http://ericfickes.com/2009/02/create-a-delimited-list-of-sortedlist-keys-in-c/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I love C#, but miss the simplicity of PHP sometimes.  Specifically when dealing with collections.  Recently I ran into a situation where <a title="Read the docs on implode( glue, array_pieces )" href="http://php.net/implode" target="_blank">PHP&#8217;s implode</a> would have been perfect, but I wasn&#8217;t able to find any quick and easy built in solution.</p>
<p>I would like to be able to do this</p>
<pre class="brush: csharp; title: ; notranslate">
string id_list = implode( &quot;,&quot;, mySortedList.Keys );
</pre>
<p>I&#8217;m not aware of any built in ways to do this, so I wrote the following helper function.</p>
<pre class="brush: csharp; title: ; notranslate">
///
/// Pass in a SortedList and this will return a string containing a delimited
/// list of keys separated by delim
///
///

///

/// key1{DELIM}key2{DELIM}keyN
public static string SortedListKeysToDelimList(SortedList sl, string delim)
{
StringBuilder sb_keys = new StringBuilder();

foreach (DictionaryEntry dl in sl)
{
sb_keys.Append( dl.Key.ToString() );

// append DELIM only if we're NOT on the last entry
if (dl.Key != sl.GetKey(sl.Keys.Count - 1))
{
sb_keys.Append( delim );
}
}

return sb_keys.ToString();
}
</pre>
<p>If there is any better way to do this, please leave me a comment.</p>
]]></content:encoded>
			<wfw:commentRss>http://ericfickes.com/2009/02/create-a-delimited-list-of-sortedlist-keys-in-c/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

