<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>LINQ Cookbook, Recipe 5: Concatenating the selected strings from a CheckedListBox (Kit George)</title><link>http://blogs.msdn.com/vbteam/archive/2007/07/03/linq-cookbook-recipe-5-concatenating-the-selected-strings-from-a-checkedlistbox.aspx</link><description>Ingredients: - Visual Studio 2008 (Beta2 or Higher) Categories: LINQ-To-Objects, LINQ and WinForms Instructions: Open Visual Studio 2008, and Click ‘File/New Project’. Create a new Windows Forms Application project From the toolbox, drag a CheckedListBox</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: LINQ Cookbook, Recipe 5: Concatenating the selected strings from a CheckedListBox</title><link>http://blogs.msdn.com/vbteam/archive/2007/07/03/linq-cookbook-recipe-5-concatenating-the-selected-strings-from-a-checkedlistbox.aspx#3679946</link><pubDate>Wed, 04 Jul 2007 05:49:34 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3679946</guid><dc:creator>Bill_McC</dc:creator><description>&lt;p&gt;Should use a StringBuilder instead of String in the Concat method.&lt;/p&gt;
&lt;p&gt;Which is kind of interesting becuase how do you use a string builder effectively with the lambda function approach ?&lt;/p&gt;
</description></item><item><title>Lambdas : some good, some very bad..</title><link>http://blogs.msdn.com/vbteam/archive/2007/07/03/linq-cookbook-recipe-5-concatenating-the-selected-strings-from-a-checkedlistbox.aspx#3680017</link><pubDate>Wed, 04 Jul 2007 05:54:27 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3680017</guid><dc:creator>@ Head</dc:creator><description>&lt;p&gt;One of the new things in Orcas is Lambda functions (or inline functions/BLOCKED EXPRESSION. Although&lt;/p&gt;
</description></item><item><title>re: LINQ Cookbook, Recipe 5: Concatenating the selected strings from a CheckedListBox</title><link>http://blogs.msdn.com/vbteam/archive/2007/07/03/linq-cookbook-recipe-5-concatenating-the-selected-strings-from-a-checkedlistbox.aspx#3680160</link><pubDate>Wed, 04 Jul 2007 06:05:41 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3680160</guid><dc:creator>Bill_McC</dc:creator><description>&lt;p&gt;oh, and although I assume that lambda does work in this case because each item is as String, the CheckListBox items might not be as string, so it's probably safer if the code was&lt;/p&gt;
&lt;p&gt; x.ToString &amp;amp; &amp;quot;, &amp;quot; &amp;amp; y.ToString&lt;/p&gt;
&lt;p&gt;Also I presume that the code you showed would be reliant on Option Strict Off, as there is no way the compiler could infer the type to be as String becuase the collection is as Object.&lt;/p&gt;
</description></item><item><title>re: LINQ Cookbook, Recipe 5: Concatenating the selected strings from a CheckedListBox</title><link>http://blogs.msdn.com/vbteam/archive/2007/07/03/linq-cookbook-recipe-5-concatenating-the-selected-strings-from-a-checkedlistbox.aspx#3681812</link><pubDate>Wed, 04 Jul 2007 09:21:23 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3681812</guid><dc:creator>Klaus Enevoldsen</dc:creator><description>&lt;p&gt;I'm missing one ingredient: Visual Studio 2008 (Beta2 or Higher). :-)&lt;/p&gt;
&lt;p&gt;Anyway it would be better to check the length of the &amp;quot;str&amp;quot; variable in stead of comparing it to an empty string &amp;quot;&amp;quot;.&lt;/p&gt;
&lt;p&gt;Public Module AggregateModule&lt;/p&gt;
&lt;p&gt;&amp;lt;Extension()&amp;gt; Public Function Concat(Of Type)( _&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;ByVal ie As IEnumerable(Of Type)) As String&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;Dim str As String = &amp;quot;&amp;quot;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;For Each item In ie&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;If str.Length() &amp;gt; 0 Then str &amp;amp;= &amp;quot;,&amp;quot;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;str &amp;amp;= item.ToString()&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;Next&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;Return str&lt;/p&gt;
&lt;p&gt; &amp;nbsp;End Function&lt;/p&gt;
&lt;p&gt;End Module&lt;/p&gt;
</description></item><item><title>re: LINQ Cookbook, Recipe 5: Concatenating the selected strings from a CheckedListBox</title><link>http://blogs.msdn.com/vbteam/archive/2007/07/03/linq-cookbook-recipe-5-concatenating-the-selected-strings-from-a-checkedlistbox.aspx#3682854</link><pubDate>Wed, 04 Jul 2007 11:12:43 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3682854</guid><dc:creator>Kit George</dc:creator><description>&lt;p&gt;Agreed on the length check, and agreed on the builder generally. For short concats, builders won't make much difference of course, but if we're building long strings, StringBuilder would be definitely preferred.&lt;/p&gt;
</description></item><item><title>re: LINQ Cookbook, Recipe 5: Concatenating the selected strings from a CheckedListBox</title><link>http://blogs.msdn.com/vbteam/archive/2007/07/03/linq-cookbook-recipe-5-concatenating-the-selected-strings-from-a-checkedlistbox.aspx#4048744</link><pubDate>Wed, 25 Jul 2007 23:36:14 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4048744</guid><dc:creator>Ken Getz</dc:creator><description>&lt;p&gt;This may be less efficient, but it makes me happier (and works with Option Strict On):&lt;/p&gt;
&lt;p&gt;&amp;lt;Extension()&amp;gt; Public Function Concat(Of Type)( _&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;ByVal ie As IEnumerable(Of Type)) As String&lt;/p&gt;
&lt;p&gt; &amp;nbsp;Dim items As New List(Of String)&lt;/p&gt;
&lt;p&gt; &amp;nbsp;For Each item In ie&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;items.Add(item.ToString())&lt;/p&gt;
&lt;p&gt; &amp;nbsp;Next&lt;/p&gt;
&lt;p&gt; &amp;nbsp;Return String.Join(&amp;quot;, &amp;quot;, items.ToArray())&lt;/p&gt;
&lt;p&gt;End Function&lt;/p&gt;
&lt;p&gt;I just hate that &amp;quot;check to ensure you haven't already got an item to avoid the leading comma problem&amp;quot; issue. It just bugs me...&lt;/p&gt;
&lt;p&gt;And I keep thinking that I should be able to cast ie As IEnumerable into List(Of String), to avoid adding each item in turn, but I sure can't figure out the syntax.&lt;/p&gt;
</description></item><item><title>re: LINQ Cookbook, Recipe 5: Concatenating the selected strings from a CheckedListBox</title><link>http://blogs.msdn.com/vbteam/archive/2007/07/03/linq-cookbook-recipe-5-concatenating-the-selected-strings-from-a-checkedlistbox.aspx#4051036</link><pubDate>Thu, 26 Jul 2007 01:58:48 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4051036</guid><dc:creator>VBTeam</dc:creator><description>&lt;p&gt;nice variant, thanks Ken&lt;/p&gt;
</description></item></channel></rss>