<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" 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>ChangeAll extension method alters every item in an iCollection(Of T)</title>
    <link>http://blogs.lotterypost.com/speednet/2008/1/changeall-extension-method-alters-every-item.htm</link>
    <atom:link href="http://www.lotterypost.com/rss/blogcomments/20433" rel="self" type="application/rss+xml" />
    <description>Speednet's Blog: ChangeAll extension method alters every item in an iCollection(Of T)</description>
    <dc:language>en-us</dc:language>
    <generator>Lottery Post RSS Generator</generator>
    <item>
      <title>Comment #2</title>
      <link>http://blogs.lotterypost.com/speednet/2008/1/changeall-extension-method-alters-every-item.htm</link>
      <guid isPermaLink="true">http://blogs.lotterypost.com/speednet/2008/1/changeall-extension-method-alters-every-item.htm</guid>
      <pubDate>Thu, 03 Jan 2008 03:46:15 GMT</pubDate>
      <dc:creator>Todd</dc:creator>
      <description><![CDATA[Ah yes, that's another great new VB feature: Xml literals.  What a tremendous time saver, and what a huge improvement in readability!  Sometimes these new features are so radically good that I forget to use them.

The source code thing I'm only mildly excited about.  To be honest there aren't all that many times I wished for it, and since it's available I have never had the need.

I think MS is going to do a big launch event, but I can't remember when it will be.  I've been using VS2008 for ... [&nbsp;<a href="http://blogs.lotterypost.com/speednet/2008/1/changeall-extension-method-alters-every-item.htm">More</a>&nbsp;]]]></description>
      <category>Todd</category>
    </item>
    <item>
      <title>Comment #1</title>
      <link>http://blogs.lotterypost.com/speednet/2008/1/changeall-extension-method-alters-every-item.htm</link>
      <guid isPermaLink="true">http://blogs.lotterypost.com/speednet/2008/1/changeall-extension-method-alters-every-item.htm</guid>
      <pubDate>Wed, 02 Jan 2008 23:27:21 GMT</pubDate>
      <dc:creator>LottoMining</dc:creator>
      <description><![CDATA[Yes, that does look like an extremely useful function.  I wonder if MSFT added it to go with 3.5 Framework's ability to look at the actual source code of .NET â€¦ so if you see something you don't like you can use the Extension method(s) and tweak to your liking.  

I'll add it to my list of things to look into when I get my hands on VS/SQL 2008 in February (if they have a huge launch like they did in November of 2005).  I was most looking forward to the XML support built into "the new VB", th... [&nbsp;<a href="http://blogs.lotterypost.com/speednet/2008/1/changeall-extension-method-alters-every-item.htm">More</a>&nbsp;]]]></description>
      <category>LottoMining</category>
    </item>
    <item>
      <title>Original Blog Entry: ChangeAll extension method alters every item in an iCollection(Of T)</title>
      <link>http://blogs.lotterypost.com/speednet/2008/1/changeall-extension-method-alters-every-item.htm</link>
      <guid isPermaLink="true">http://blogs.lotterypost.com/speednet/2008/1/changeall-extension-method-alters-every-item.htm</guid>
      <pubDate>Wed, 02 Jan 2008 21:26:42 GMT</pubDate>
      <dc:creator>Speednet</dc:creator>
      <description><![CDATA[<p>My favorite feature of the new .NET 3.5 framework is extension methods.&nbsp; Ever since I heard they would be available in this version of the .NET framework I have been designing functions in a way that they could be easily converted to extension methods.</p><p>For the unenlightened, extension methods are a new feature of the .NET 3.5 framework that allows you to extend any class &mdash; whether it is a built-in class, a third-party class, or your own class.</p><p>When you create an extension method, you can call the new method as if it were a native method of the class.</p><p>As an easy-to-understand example, I created an extension of the .NET String class called SuperTrim().&nbsp; The method works like the built-in Trim() method, but instead of just trimming spaces from the front and back of a string, it trims any kind of control characters (any character with an ASCII code of less than 32, plus a few others).</p><p>After creating the extension method, I can apply SuperTrim() to an string in exactly the same way I would apply a regular Trim():</p><p><span style="font-size: 11px; font-family: courier new,courier">newString = oldString.SuperTrim()</span></p><p>Now <span style="text-decoration: underline">that's</span> cool!&nbsp;</p><p>Last week I&nbsp;came upon&nbsp;a scenario in a program where I had to manipulate all of the items in a collection, so I tried using the built-in ForEach() method.&nbsp; The trouble is that ForEach() is designed to <strong>do something with</strong> all the items in a collection, but not to <strong>change</strong> all of the items in a collection.</p><p>ForEach() passes each item, one by one, to your specified function, but it explicitly only passes the item by value, not&nbsp;by reference.&nbsp; If your function changes the value passed, it is not changed in the collection &mdash; only within the scope of your function.</p><p>ForEach() also does not pass an index number or any other value that could help determine which item in the collection to change, so any attempt to use ForEach() to <strong>change</strong> items in the original collection would be a messy affair.</p><p>In response, I created an extension to iCollection called ChangeAll().&nbsp; You pass a function to ChangeAll() that will receive each item, one by one, and the return value from your&nbsp;function will become the new value of that item in the collection.</p><p>Incidentally, ChangeAll() works great with the new lambda expressions &mdash; another won....</p><p>[ <a href="http://blogs.lotterypost.com/speednet/2008/1/changeall-extension-method-alters-every-item.htm">More</a> ]</p>]]></description>
      <category>* Original Blog Entry</category>
      <wfw:comment>http://www.lotterypost.com/blogentry/20433</wfw:comment>
    </item>
  </channel>
</rss>
