<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Linq on Strathweb. A free flowing tech monologue.</title>
    <link>https://www.strathweb.com/categories/linq/</link>
    <description>Recent content in Linq on Strathweb. A free flowing tech monologue.</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-us</language>
    <lastBuildDate>Fri, 16 Mar 2012 10:02:31 +0000</lastBuildDate><atom:link href="https://www.strathweb.com/categories/linq/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>LINQ foreach iteration variable capturing and how it’s fixed in Visual Studio 11</title>
      <link>https://www.strathweb.com/2012/03/linq-foreach-iteration-variable-capturing-and-how-its-fixed-in-visual-studio-11/</link>
      <pubDate>Fri, 16 Mar 2012 10:02:31 +0000</pubDate>
      
      <guid>https://www.strathweb.com/2012/03/linq-foreach-iteration-variable-capturing-and-how-its-fixed-in-visual-studio-11/</guid>
      <description>&lt;p&gt;A while a go, the C# community got surprised by another &lt;a href=&#34;http://en.wikipedia.org/wiki/Gotcha_(programming)&#34; target=&#34;_blank&#34;&gt;GOTCHA&lt;/a&gt;, discovering that using a foreach iteration variable inside a LINQ query, may not always yield the expected results. The variable gets captured by the foreach loop and, due to the evil work of &lt;a href=&#34;http://en.wikipedia.org/wiki/Closure_(computer_science)&#34; target=&#34;_blank&#34;&gt;closure&lt;/a&gt;, it remains scoped outside of the LINQ query itself living its own life so to speak. This has now been corrected in the Visual Studio 11 Beta.&lt;/p&gt;</description>
    </item>
    
  </channel>
</rss>
